From nobody Sun May 19 04:05:29 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1702897556169244.3934129214931; Mon, 18 Dec 2023 03:05:56 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 1574B1C1C; Mon, 18 Dec 2023 06:05:55 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 11B891B40; Mon, 18 Dec 2023 06:03:09 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id E78461ADA; Mon, 18 Dec 2023 06:03:03 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 0F7201AC5 for ; Mon, 18 Dec 2023 06:03:02 -0500 (EST) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-520-hh4XyCpJMqq4ZQIBAVEWDQ-1; Mon, 18 Dec 2023 06:03:00 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2370629AC027 for ; Mon, 18 Dec 2023 11:03:00 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9830940C6EB9 for ; Mon, 18 Dec 2023 11:02:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: hh4XyCpJMqq4ZQIBAVEWDQ-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 1/2] qemuxml2argvmock: Mock qemuExtVhostUserGPUPrepareDomain Date: Mon, 18 Dec 2023 12:02:56 +0100 Message-ID: <0d23980b8e06a9ea9d75bd2e503b0f72093625bd.1702897199.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: BEH7YQFLNZCRUWUXXRGR7MBPO5TQOPPL X-Message-ID-Hash: BEH7YQFLNZCRUWUXXRGR7MBPO5TQOPPL X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1702897558010100001 Noticed when breaking on 'fork()' in qemuxml2argvtest (output slihtly trimmed, of unimportant file locations: #0 0x00007ffff75abf18 in fork () at /lib64/libc.so.6 #1 0x00007ffff7b88387 in virFork () at ../../../libvirt/src/util/vircomm= and.c:282 #2 0x00007ffff7b8a7d2 in virExec (cmd=3D0x55555740d440) at ../../../libv= irt/src/util/vircommand.c:741 #3 virCommandRunAsync (cmd=3Dcmd@entry=3D0x55555740d440, pid=3Dpid@entry= =3D0x0) at ../../../libvirt/src/util/vircommand.c:2658 #4 0x00007ffff7b8c04f in virCommandRun (cmd=3Dcmd@entry=3D0x55555740d440= , exitstatus=3Dexitstatus@entry=3D0x0) #5 0x00007ffff79f6daa in qemuVhostUserFillDomainGPU (driver=3Ddriver@ent= ry=3D0x555555586120 , video=3D0x5555573e8d80) #6 0x00007ffff79f73f5 in qemuExtVhostUserGPUPrepareDomain (driver=3Ddriv= er@entry=3D0x555555586120 , video=3D) #7 0x00007ffff797c569 in qemuExtDevicesPrepareDomain (driver=3Ddriver@en= try=3D0x555555586120 , vm=3Dvm@entry=3D0x5555573dfef0) #8 0x00007ffff79d69ef in qemuProcessPrepareDomain #9 0x00007ffff79dda36 in qemuProcessCreatePretendCmdPrepare #10 0x000055555556fa28 in testCompareXMLToArgvCreateArgs #11 testCompareXMLToArgv (data=3D0x5555573440f0) at ../../../libvirt/test= s/qemuxml2argvtest.c:733 #12 0x0000555555570f7a in virTestRun #13 0x0000555555571201 in virTestRunLog (ret=3D0x7fffffffdb4c, title=3D0x55555697c360 "QEMU XML-2-ARGV virtio= -options.x86_64-latest", body=3D0x55555556f820 , data= =3D0x5555573440f0) at ../../../libvirt/tests/testutils.c:198 #14 0x000055555555c1b9 in testRun Code paths in 'qemuProcessPrepareDomain' should not invoke external helpers. Note this in a comment and mock the function for now. It will need a more complex refactor. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_vhost_user_gpu.c | 4 ++++ src/qemu/qemu_vhost_user_gpu.h | 2 +- tests/qemuxml2argvmock.c | 9 +++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_vhost_user_gpu.c b/src/qemu/qemu_vhost_user_gpu.c index 933adfe8de..cca76526d1 100644 --- a/src/qemu/qemu_vhost_user_gpu.c +++ b/src/qemu/qemu_vhost_user_gpu.c @@ -78,6 +78,10 @@ qemuVhostUserGPUGetPid(const char *stateDir, } +/** TODO: this is called from qemuProcessPrepareDomain which is NOT suppos= ed to + * query the host in any way. This function is mocked in qemuxml2argvmock.= so + * to prevent probing the host vgpu process capabilities. + */ int qemuExtVhostUserGPUPrepareDomain(virQEMUDriver *driver, virDomainVideoDef *video) { diff --git a/src/qemu/qemu_vhost_user_gpu.h b/src/qemu/qemu_vhost_user_gpu.h index 2b86982cb8..d19798d781 100644 --- a/src/qemu/qemu_vhost_user_gpu.h +++ b/src/qemu/qemu_vhost_user_gpu.h @@ -26,7 +26,7 @@ int qemuExtVhostUserGPUPrepareDomain(virQEMUDriver *driver, virDomainVideoDef *video) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) - G_GNUC_WARN_UNUSED_RESULT; + G_GNUC_WARN_UNUSED_RESULT G_NO_INLINE; int qemuExtVhostUserGPUStart(virQEMUDriver *driver, virDomainObj *vm, diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c index 52c44b2ed0..2deccd79c4 100644 --- a/tests/qemuxml2argvmock.c +++ b/tests/qemuxml2argvmock.c @@ -37,6 +37,7 @@ #include "qemu/qemu_command.h" #include #include +#include "qemu/qemu_vhost_user_gpu.h" #define VIR_FROM_THIS VIR_FROM_NONE @@ -267,3 +268,11 @@ virIdentityEnsureSystemToken(void) { return g_strdup("3de80bcbf22d4833897f1638e01be9b2"); } + + +int +qemuExtVhostUserGPUPrepareDomain(virQEMUDriver *driver G_GNUC_UNUSED, + virDomainVideoDef *video G_GNUC_UNUSED) +{ + return 0; +} --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Sun May 19 04:05:29 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1702897633493880.9826143938925; Mon, 18 Dec 2023 03:07:13 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 795ED1BAB; Mon, 18 Dec 2023 06:07:12 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 468BC1B51; Mon, 18 Dec 2023 06:03:18 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 30FEE1ADA; Mon, 18 Dec 2023 06:03:05 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 1E3681ABA for ; Mon, 18 Dec 2023 06:03:04 -0500 (EST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-197-pWySutIsOWim7WG-HogghQ-1; Mon, 18 Dec 2023 06:03:01 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 022F485A58A for ; Mon, 18 Dec 2023 11:03:01 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A16740C6EBA for ; Mon, 18 Dec 2023 11:03:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SUBJ_BRKN_WORDNUMS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.4 X-MC-Unique: pWySutIsOWim7WG-HogghQ-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 2/2] qemuxml2argvmock: Poison virCommandRun and virFork from test context Date: Mon, 18 Dec 2023 12:02:57 +0100 Message-ID: <223d4a8e8d5348f9bc60adfaa675424dbe3f7d19.1702897199.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: Y7I5XX7APAEVCON4IWGQI3EZYMPCJ4VB X-Message-ID-Hash: Y7I5XX7APAEVCON4IWGQI3EZYMPCJ4VB X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1702897634629100001 We don't want to ever run an actuall command in qemuxml2argvtest poison the helper functions we have for running commands. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/util/vircommand.h | 4 ++-- tests/qemuxml2argvmock.c | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/util/vircommand.h b/src/util/vircommand.h index 9bcdce35b9..566ac15947 100644 --- a/src/util/vircommand.h +++ b/src/util/vircommand.h @@ -39,7 +39,7 @@ typedef struct _virCommand virCommand; * call any function that is not async-signal-safe. */ typedef int (*virExecHook)(void *data); -pid_t virFork(void) G_GNUC_WARN_UNUSED_RESULT; +pid_t virFork(void) G_GNUC_WARN_UNUSED_RESULT G_NO_INLINE; virCommand *virCommandNew(const char *binary) ATTRIBUTE_NONNULL(1); @@ -184,7 +184,7 @@ int virCommandGetArgList(virCommand *cmd, char ***args); int virCommandExec(virCommand *cmd, gid_t *groups, int ngroups) G_GNUC_WAR= N_UNUSED_RESULT; int virCommandRun(virCommand *cmd, - int *exitstatus) G_GNUC_WARN_UNUSED_RESULT; + int *exitstatus) G_GNUC_WARN_UNUSED_RESULT G_NO_INLINE; int virCommandRunAsync(virCommand *cmd, pid_t *pid) G_GNUC_WARN_UNUSED_RESULT; diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c index 2deccd79c4..0ee8fbba79 100644 --- a/tests/qemuxml2argvmock.c +++ b/tests/qemuxml2argvmock.c @@ -276,3 +276,22 @@ qemuExtVhostUserGPUPrepareDomain(virQEMUDriver *driver= G_GNUC_UNUSED, { return 0; } + + +int +virCommandRun(virCommand *cmd, + int *exitstatus G_GNUC_UNUSED) +{ + const char *path =3D virCommandGetBinaryPath(cmd); + + fprintf(stderr, "\nattempted virCommandRun() (path=3D%s) from test con= text\n", NULLSTR(path)); + return -1; +} + + +pid_t +virFork(void) +{ + fprintf(stderr, "\nattempted virFork() in test context\n"); + return -1; +} --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org