From nobody Sat May 11 08:38:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1649947482; cv=none; d=zohomail.com; s=zohoarc; b=YnjwSzzd+6lDUBvNEqEaCMlqqEGX5OjFjhbcKWapzSBsYpscXJ4cQvvOszw3xV6IayUf/LSTlEEhgiCJ9srfIQ7v/cJyhukfz2JzzTDjB+qPxpqkgzzknX/NBgB3q4gqqgWr7Dvrmcafj4av8Vj+9Mw3lCZB1KJpKznr5Q+4kec= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1649947482; 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; bh=OdooBf+3QjBKtWNeaijTxQZbc28vk6KTVhxvcMiY2yE=; b=Q84c9+IkitnLHtZCs+42gz+lIM1IH97GaEKSlDHzx/Gnbrr4IDgUDDQnpd1Qwm8C7OWc/SvRpw4SgnmGsWeUV2piH/kMW6tP5dWm2rmDFxYgox4nmWWhZTei8XaPu8konRV/IwGUkV/MV9jqpSiaEV2ZnCPtKctqVDfj1WrJOvA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1649947482204756.7549470518534; Thu, 14 Apr 2022 07:44:42 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-307-ashvoNfMOf-b8eBNTm7M_A-1; Thu, 14 Apr 2022 10:44:34 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 655503C1618B; Thu, 14 Apr 2022 14:44:32 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B69C407F770; Thu, 14 Apr 2022 14:44:31 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 22F151940354; Thu, 14 Apr 2022 14:44:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 290A519451F2 for ; Thu, 14 Apr 2022 14:44:28 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 1ABA64229C4; Thu, 14 Apr 2022 14:44:28 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id B6F674229B7 for ; Thu, 14 Apr 2022 14:44:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649947480; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=OdooBf+3QjBKtWNeaijTxQZbc28vk6KTVhxvcMiY2yE=; b=gI4RheSfDH+HlvSN0VWz2HcvYCwh1ulAEJe0pkU4Cp7sk8hL9M+KeTxgQAhywhIipyL5j7 mA22HzSY03tDLNsgDwUO9tciGt5qciNO+w5zON7ivyAUbCdtAWxDsr2bxRa6aLEHj3mpVu 8QmXESN96Jvf45IguQXsOb6AxlsGO7s= X-MC-Unique: ashvoNfMOf-b8eBNTm7M_A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/2] qemu_processpriv: Fix #error message Date: Thu, 14 Apr 2022 16:44:24 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1649947484288100002 Content-Type: text/plain; charset="utf-8"; x-default="true" The point of qemu_processpriv.h file is to allow a small subset of functions to be called from test suite but not elsewhere. This is implemented by requiring everybody that includes the file to define a macro. If not done so, an error is printed at compile time. However, this error message contains a typo because it mentions qemu_process_priv.h while the file is called qemu_processpriv.h. Signed-off-by: Michal Privoznik --- src/qemu/qemu_processpriv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_processpriv.h b/src/qemu/qemu_processpriv.h index 2bc60ce103..9cb176e97c 100644 --- a/src/qemu/qemu_processpriv.h +++ b/src/qemu/qemu_processpriv.h @@ -20,7 +20,7 @@ */ =20 #ifndef LIBVIRT_QEMU_PROCESSPRIV_H_ALLOW -# error "qemu_process_priv.h may only be included by qemu_process.c or tes= t suites" +# error "qemu_processpriv.h may only be included by qemu_process.c or test= suites" #endif /* LIBVIRT_QEMU_PROCESSPRIV_H_ALLOW */ =20 #pragma once --=20 2.35.1 From nobody Sat May 11 08:38:24 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=1649947480; cv=none; d=zohomail.com; s=zohoarc; b=TxvMj52SciuMzrdZ2apD9DT6EdkDNgIvsVY3j/wsDD4dvZRFd+YyEp3PJ9SwpFUdznPb0wkrDd44R8jWrAjBaicSMnOG5yV/Pw40NtxdIg9WVEAmBqUXxpnVMIuiL2wmV/RGmUzSN07szpM0zQWFHBP1U8g9bRZesulqQvBhLF4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1649947480; 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; bh=Xkrg1efvbDV9rKIkg/Z7pUolu2V67ptYl5LtBPmFDh0=; b=AaIIBlA2r+I1zlgGgBTn56Thh2esB4JT+kpGUom8AqlJHqME3ZtahRIp4QsJwEOSDqWWboHEoy8dLYuZESeBLRzWMLaksxG6h5tNtc72bZkWwkou8hPde9VyzmQ+Scd5mOPDRXjuSRtFwKljUm6YCKjO4kNLaHi8LEuitpbRrv8= 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 1649947480079394.39449078732207; Thu, 14 Apr 2022 07:44:40 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-152-O4BK0-RLPvqlWWl0AT8YYA-1; Thu, 14 Apr 2022 10:44:35 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0CCA61C0904B; Thu, 14 Apr 2022 14:44:33 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id EA6334229B7; Thu, 14 Apr 2022 14:44:32 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 69D721940361; Thu, 14 Apr 2022 14:44:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E5C441940350 for ; Thu, 14 Apr 2022 14:44:28 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C8A474229C4; Thu, 14 Apr 2022 14:44:28 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5443B4229B7 for ; Thu, 14 Apr 2022 14:44:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649947479; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Xkrg1efvbDV9rKIkg/Z7pUolu2V67ptYl5LtBPmFDh0=; b=Fyk5Mk1UI6PyOaJuxrckXISpzJCdr2JOhXBFqgIeaM/Brl3zkyQ/dOyiJclIzA0TK8lahB dGgGGVL6wkoIJ5n2UP+JGOvfV3T8jnrIt2vtvqmF/VCN0F4BzlV3qKlEjp8c5rSDaxfaF+ Gt3z3wn+UlDDhZv9wMvV4/CQmIxTBOY= X-MC-Unique: O4BK0-RLPvqlWWl0AT8YYA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/2] tests: Turn testQemuPrepareHostBackendChardevOne() into proper mock Date: Thu, 14 Apr 2022 16:44:25 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1649947480625100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Commit v8.0.0-409-gad81aa8ad0 added another function into qemuhotplugmock.c. However, it did so in a bit clumsy way: the function calls testQemuPrepareHostBackendChardevOne() which is not exported and is a part of libtest_utils_qemu.a static library. Fortunately, qemuhotplugtest links with it and thus we did not see any trouble at runtime as the symbol was resolved into something in the binary. The problem arose when the test is ran under valgrind. There the symbol is not resolved (although I don't fully understand why). Nevertheless, the testQemuPrepareHostBackendChardevOne() function can be turned into a proper mock of qemuProcessPrepareHostBackendChardev() (since they former was heavily inspired by the latter). Moreover, if the QEMU stub driver config is changed so that stdioLogD is false, then more code can be cleaned up: 1) qemuProcessPrepareHostBackendChardevHotplug() mock from qemuhotplugmock.c can be dropped (effectively reverting the original commit), 2) testCompareXMLToArgvCreateArgs() can call full blown qemuProcessPrepareHostBackendChardev() instead of open coding it. Signed-off-by: Michal Privoznik --- src/qemu/qemu_process.c | 13 +---- src/qemu/qemu_processpriv.h | 18 ++++++ tests/qemuhotplugmock.c | 11 ---- tests/qemuhotplugtest.c | 1 + tests/qemumonitorjsontest.c | 7 ++- tests/qemuxml2argvmock.c | 94 +++++++++++++++++++++++++++++++ tests/qemuxml2argvtest.c | 10 ++-- tests/testutilsqemu.c | 107 +----------------------------------- tests/testutilsqemu.h | 4 -- 9 files changed, 126 insertions(+), 139 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index e1ac4c7032..c7949e8a34 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6773,16 +6773,7 @@ qemuProcessPrepareHostBackendChardevFileHelper(const= char *path, } =20 =20 -struct qemuProcessPrepareHostBackendChardevData { - qemuDomainObjPrivate *priv; - virLogManager *logManager; - virQEMUDriverConfig *cfg; - virDomainDef *def; - const char *fdprefix; -}; - - -static int +int qemuProcessPrepareHostBackendChardevOne(virDomainDeviceDef *dev, virDomainChrSourceDef *chardev, void *opaque) @@ -6900,7 +6891,7 @@ qemuProcessPrepareHostBackendChardevOne(virDomainDevi= ceDef *dev, /* prepare the chardev backends for various devices: * serial/parallel/channel chardevs, vhost-user disks, vhost-user network * interfaces, smartcards, shared memory, and redirdevs */ -static int +int qemuProcessPrepareHostBackendChardev(virDomainObj *vm) { qemuDomainObjPrivate *priv =3D vm->privateData; diff --git a/src/qemu/qemu_processpriv.h b/src/qemu/qemu_processpriv.h index 9cb176e97c..34ab829876 100644 --- a/src/qemu/qemu_processpriv.h +++ b/src/qemu/qemu_processpriv.h @@ -27,6 +27,7 @@ =20 #include "domain_conf.h" #include "qemu_monitor.h" +#include "qemu_domain.h" =20 /* * This header file should never be used outside unit tests. @@ -38,3 +39,20 @@ void qemuProcessHandleDeviceDeleted(qemuMonitor *mon, void *opaque); =20 int qemuProcessQMPInitMonitor(qemuMonitor *mon); + +struct qemuProcessPrepareHostBackendChardevData { + qemuDomainObjPrivate *priv; + virLogManager *logManager; + virQEMUDriverConfig *cfg; + virDomainDef *def; + const char *fdprefix; +}; + + +int +qemuProcessPrepareHostBackendChardevOne(virDomainDeviceDef *dev, + virDomainChrSourceDef *chardev, + void *opaque) G_GNUC_NO_INLINE; + +int +qemuProcessPrepareHostBackendChardev(virDomainObj *vm); diff --git a/tests/qemuhotplugmock.c b/tests/qemuhotplugmock.c index d618ff9d06..a8dbc45b60 100644 --- a/tests/qemuhotplugmock.c +++ b/tests/qemuhotplugmock.c @@ -21,7 +21,6 @@ #include "qemu/qemu_hotplug.h" #include "qemu/qemu_interface.h" #include "qemu/qemu_process.h" -#include "testutilsqemu.h" #include "conf/domain_conf.h" #include "virdevmapper.h" #include "virutil.h" @@ -102,16 +101,6 @@ qemuInterfaceVDPAConnect(virDomainNetDef *net G_GNUC_U= NUSED) } =20 =20 -int -qemuProcessPrepareHostBackendChardevHotplug(virDomainObj *vm, - virDomainDeviceDef *dev) -{ - return qemuDomainDeviceBackendChardevForeachOne(dev, - testQemuPrepareHostBac= kendChardevOne, - vm); -} - - /* we don't really want to send fake FDs across the monitor */ int qemuMonitorIOWriteWithFD(qemuMonitor *mon, diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index 21302e0fce..3815011c1b 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -913,4 +913,5 @@ VIR_TEST_MAIN_PRELOAD(mymain, VIR_TEST_MOCK("virpci"), VIR_TEST_MOCK("domaincaps"), VIR_TEST_MOCK("virprocess"), + VIR_TEST_MOCK("qemuxml2argv"), VIR_TEST_MOCK("qemuhotplug")); diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 278d7ba765..0d5624760d 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -36,6 +36,8 @@ #include "qemu/qemu_migration_params.h" #define LIBVIRT_QEMU_MIGRATION_PARAMSPRIV_H_ALLOW #include "qemu/qemu_migration_paramspriv.h" +#define LIBVIRT_QEMU_PROCESSPRIV_H_ALLOW +#include "qemu/qemu_processpriv.h" =20 #define VIR_FROM_THIS VIR_FROM_NONE =20 @@ -742,7 +744,7 @@ qemuMonitorJSONTestAttachChardev(virDomainXMLOption *xm= lopt, "'logappend':= false}}}"); =20 chrdev.source =3D chr; - ignore_value(testQemuPrepareHostBackendChardevOne(&dev, chr, NULL)= ); + ignore_value(qemuProcessPrepareHostBackendChardevOne(&dev, chr, NU= LL)); qemuFDPassTransferMonitorFake(charpriv->sourcefd); qemuFDPassTransferMonitorFake(charpriv->logfd); CHECK("file", false, @@ -3284,4 +3286,5 @@ mymain(void) return (ret =3D=3D 0) ? EXIT_SUCCESS : EXIT_FAILURE; } =20 -VIR_TEST_MAIN(mymain) +VIR_TEST_MAIN_PRELOAD(mymain, + VIR_TEST_MOCK("qemuxml2argv")); diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c index 08f176667d..c0e73f44ac 100644 --- a/tests/qemuxml2argvmock.c +++ b/tests/qemuxml2argvmock.c @@ -19,6 +19,7 @@ #include =20 #define LIBVIRT_VIRIDENTITYPRIV_H_ALLOW +#define LIBVIRT_QEMU_PROCESSPRIV_H_ALLOW =20 #include "internal.h" #include "viralloc.h" @@ -41,6 +42,7 @@ #include "virutil.h" #include "qemu/qemu_interface.h" #include "qemu/qemu_command.h" +#include "qemu/qemu_processpriv.h" #include #include #include @@ -292,6 +294,98 @@ qemuInterfaceVDPAConnect(virDomainNetDef *net G_GNUC_U= NUSED) return 1732; } =20 + +int +qemuProcessPrepareHostBackendChardevOne(virDomainDeviceDef *dev, + virDomainChrSourceDef *chardev, + void *opaque) +{ + struct qemuProcessPrepareHostBackendChardevData *data =3D opaque; + qemuDomainObjPrivate *priv =3D data ? data->priv : NULL; + qemuDomainChrSourcePrivate *charpriv =3D QEMU_DOMAIN_CHR_SOURCE_PRIVAT= E(chardev); + int fakesourcefd =3D -1; + const char *devalias =3D NULL; + bool usefdset =3D true; + + if (dev) { + virDomainDeviceInfo *info =3D virDomainDeviceGetInfo(dev); + devalias =3D info->alias; + + /* vhost-user disk doesn't use FD passing */ + if (dev->type =3D=3D VIR_DOMAIN_DEVICE_DISK) + return 0; + + if (dev->type =3D=3D VIR_DOMAIN_DEVICE_NET) { + /* due to a historical bug in qemu we don't use FD passtrhough= for + * vhost-sockets for network devices */ + return 0; + } + + /* TPMs FD passing setup is special and handled separately */ + if (dev->type =3D=3D VIR_DOMAIN_DEVICE_TPM) + return 0; + } else { + devalias =3D "monitor"; + } + + switch ((virDomainChrType) chardev->type) { + case VIR_DOMAIN_CHR_TYPE_NULL: + case VIR_DOMAIN_CHR_TYPE_VC: + case VIR_DOMAIN_CHR_TYPE_PTY: + case VIR_DOMAIN_CHR_TYPE_DEV: + case VIR_DOMAIN_CHR_TYPE_PIPE: + case VIR_DOMAIN_CHR_TYPE_STDIO: + case VIR_DOMAIN_CHR_TYPE_UDP: + case VIR_DOMAIN_CHR_TYPE_TCP: + case VIR_DOMAIN_CHR_TYPE_SPICEVMC: + case VIR_DOMAIN_CHR_TYPE_SPICEPORT: + break; + + case VIR_DOMAIN_CHR_TYPE_FILE: + fakesourcefd =3D 1750; + break; + + case VIR_DOMAIN_CHR_TYPE_UNIX: + if (chardev->data.nix.listen) + fakesourcefd =3D 1729; + + usefdset =3D false; + break; + + case VIR_DOMAIN_CHR_TYPE_NMDM: + case VIR_DOMAIN_CHR_TYPE_LAST: + break; + } + + if (fakesourcefd !=3D -1) { + if (fcntl(fakesourcefd, F_GETFD) !=3D -1) + abort(); + + if (usefdset) + charpriv->sourcefd =3D qemuFDPassNew(devalias, priv); + else + charpriv->sourcefd =3D qemuFDPassNewDirect(devalias, priv); + + if (qemuFDPassAddFD(charpriv->sourcefd, &fakesourcefd, "-source") = < 0) + return -1; + } + + if (chardev->logfile) { + int fd =3D 1751; + + if (fcntl(fd, F_GETFD) !=3D -1) + abort(); + + charpriv->logfd =3D qemuFDPassNew(devalias, priv); + + if (qemuFDPassAddFD(charpriv->logfd, &fd, "-log") < 0) + return -1; + } + + return 0; +} + + char * virIdentityEnsureSystemToken(void) { diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index ed41b7a7a2..e10bb61785 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -34,6 +34,9 @@ # define LIBVIRT_QEMU_CAPSPRIV_H_ALLOW # include "qemu/qemu_capspriv.h" =20 +# define LIBVIRT_QEMU_PROCESSPRIV_H_ALLOW +# include "qemu/qemu_processpriv.h" + # include "testutilsqemu.h" =20 # define VIR_FROM_THIS VIR_FROM_QEMU @@ -393,12 +396,7 @@ testCompareXMLToArgvCreateArgs(virQEMUDriver *drv, VIR_QEMU_PROCESS_START_COLD) < = 0) return NULL; =20 - if (qemuDomainDeviceBackendChardevForeach(vm->def, - testQemuPrepareHostBackendCh= ardevOne, - vm) < 0) - return NULL; - - if (testQemuPrepareHostBackendChardevOne(NULL, priv->monConfig, vm) < = 0) + if (qemuProcessPrepareHostBackendChardev(vm) < 0) return NULL; =20 for (i =3D 0; i < vm->def->ndisks; i++) { diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index 105b41cbeb..e65d0cf64e 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -578,6 +578,8 @@ int qemuTestDriverInit(virQEMUDriver *driver) if (!driver->config) goto error; =20 + driver->config->stdioLogD =3D false; + /* Do this early so that qemuTestDriverFree() doesn't see (unlink) the= real * dirs. */ VIR_FREE(driver->config->stateDir); @@ -982,108 +984,3 @@ testQemuInfoClear(struct testQemuInfo *info) virObjectUnref(info->qemuCaps); g_clear_pointer(&info->args.fakeCaps, virObjectUnref); } - - -/** - * testQemuPrepareHostBackendChardevOne: - * @dev: device definition object - * @chardev: chardev source object - * @opaque: Caller is expected to pass pointer to virDomainObj or NULL - * - * This helper sets up a chardev source backend for FD passing with fake - * file descriptros. It's expected to be used as callback for - * 'qemuDomainDeviceBackendChardevForeach', thus the VM object is passed v= ia - * @opaque. Callers may pass NULL if the test scope is limited. - */ -int -testQemuPrepareHostBackendChardevOne(virDomainDeviceDef *dev, - virDomainChrSourceDef *chardev, - void *opaque) -{ - virDomainObj *vm =3D opaque; - qemuDomainObjPrivate *priv =3D NULL; - qemuDomainChrSourcePrivate *charpriv =3D QEMU_DOMAIN_CHR_SOURCE_PRIVAT= E(chardev); - int fakesourcefd =3D -1; - const char *devalias =3D NULL; - bool usefdset =3D true; - - if (vm) - priv =3D vm->privateData; - - if (dev) { - virDomainDeviceInfo *info =3D virDomainDeviceGetInfo(dev); - devalias =3D info->alias; - - /* vhost-user disk doesn't use FD passing */ - if (dev->type =3D=3D VIR_DOMAIN_DEVICE_DISK) - return 0; - - if (dev->type =3D=3D VIR_DOMAIN_DEVICE_NET) { - /* due to a historical bug in qemu we don't use FD passtrhough= for - * vhost-sockets for network devices */ - return 0; - } - - /* TPMs FD passing setup is special and handled separately */ - if (dev->type =3D=3D VIR_DOMAIN_DEVICE_TPM) - return 0; - } else { - devalias =3D "monitor"; - } - - switch ((virDomainChrType) chardev->type) { - case VIR_DOMAIN_CHR_TYPE_NULL: - case VIR_DOMAIN_CHR_TYPE_VC: - case VIR_DOMAIN_CHR_TYPE_PTY: - case VIR_DOMAIN_CHR_TYPE_DEV: - case VIR_DOMAIN_CHR_TYPE_PIPE: - case VIR_DOMAIN_CHR_TYPE_STDIO: - case VIR_DOMAIN_CHR_TYPE_UDP: - case VIR_DOMAIN_CHR_TYPE_TCP: - case VIR_DOMAIN_CHR_TYPE_SPICEVMC: - case VIR_DOMAIN_CHR_TYPE_SPICEPORT: - break; - - case VIR_DOMAIN_CHR_TYPE_FILE: - fakesourcefd =3D 1750; - break; - - case VIR_DOMAIN_CHR_TYPE_UNIX: - if (chardev->data.nix.listen) - fakesourcefd =3D 1729; - - usefdset =3D false; - break; - - case VIR_DOMAIN_CHR_TYPE_NMDM: - case VIR_DOMAIN_CHR_TYPE_LAST: - break; - } - - if (fakesourcefd !=3D -1) { - if (fcntl(fakesourcefd, F_GETFD) !=3D -1) - abort(); - - if (usefdset) - charpriv->sourcefd =3D qemuFDPassNew(devalias, priv); - else - charpriv->sourcefd =3D qemuFDPassNewDirect(devalias, priv); - - if (qemuFDPassAddFD(charpriv->sourcefd, &fakesourcefd, "-source") = < 0) - return -1; - } - - if (chardev->logfile) { - int fd =3D 1751; - - if (fcntl(fd, F_GETFD) !=3D -1) - abort(); - - charpriv->logfd =3D qemuFDPassNew(devalias, priv); - - if (qemuFDPassAddFD(charpriv->logfd, &fd, "-log") < 0) - return -1; - } - - return 0; -} diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h index 187f9b7cd3..a28f640670 100644 --- a/tests/testutilsqemu.h +++ b/tests/testutilsqemu.h @@ -142,8 +142,4 @@ void testQemuInfoSetArgs(struct testQemuInfo *info, ...); int testQemuInfoInitArgs(struct testQemuInfo *info); void testQemuInfoClear(struct testQemuInfo *info); - -int testQemuPrepareHostBackendChardevOne(virDomainDeviceDef *dev, - virDomainChrSourceDef *chardev, - void *opaque); #endif --=20 2.35.1