From nobody Mon Sep 16 18:50:28 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=1694469240; cv=none; d=zohomail.com; s=zohoarc; b=N4cqY3ZwAExp+svywnXOSX7Tio/DMt/tWtvkhKPGp4OJIi1LJLhYjObehCnAxwsRKNu5vEgQXb8IdpDc5uacn6prqfwqtAB3lySiPf05HM3Ktg/s3Y3KW7EBnI8NqnLljXqDsVdhu8ZJVfGM2Qh6gF2jSEGJH0NQv4rPNKBL/vU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694469240; h=Content-Type:Content-Transfer-Encoding:Cc: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=/MoJRM20tGLPN2shNKbSdwC5zgXCQICtcw4UTMQqiRk=; b=jSl2YVJ3CXosgO1g/elMbbQob7nH8MWNf+g/uCig/MoMjncJXxAWcK1fEotTItTY5fc+qKfIYjIG70PBWNmP32c5LYgtXbjEAkS9RJU7+BTSVQ6DGsBtLALXpnBxwi8EVhAZ26LdqRUJspltEaOP0oGTNhuDSxXC0ZtfBAiLZ/k= 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 1694469240363582.6528579019064; Mon, 11 Sep 2023 14:54:00 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx-ext.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-644-7w6VsrzeMHCdbd95tfFgjA-1; Mon, 11 Sep 2023 17:53:55 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6B26C29DD99B; Mon, 11 Sep 2023 21:53:51 +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 544962026D4B; Mon, 11 Sep 2023 21:53:51 +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 BCD8B1946A51; Mon, 11 Sep 2023 21:53:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id F3B581946597 for ; Mon, 11 Sep 2023 21:53:48 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E366640C6EC0; Mon, 11 Sep 2023 21:53:48 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.34.54]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B77CD40C6EBF; Mon, 11 Sep 2023 21:53:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694469239; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=/MoJRM20tGLPN2shNKbSdwC5zgXCQICtcw4UTMQqiRk=; b=Ohccai1iDMsfyzj9FqE4UlnqqCix5A2aBI5b9zW/mUnhIWMhy45DDjI8sstRcO4aDC4tB5 GBg02XBk8i0aitp/Mjbzr+j69/eG6gzGu4d6pEcY7fyqrSbnCn/khEEcMXBYKUarqcpZX9 KSoMPCbJVCds5KIHTcYfMLyjQCioUvE= X-MC-Unique: 7w6VsrzeMHCdbd95tfFgjA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v2 3/5] qemu: make vdpa connect function more generic Date: Mon, 11 Sep 2023 16:53:45 -0500 Message-ID: <20230911215347.1160427-4-jjongsma@redhat.com> In-Reply-To: <20230911215347.1160427-1-jjongsma@redhat.com> References: <20230911215347.1160427-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: , Cc: Peter Krempa Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: 1694469241005100005 Content-Type: text/plain; charset="utf-8"; x-default="true" qemuInterfaceVDPAConnect() was a helper function for connecting to the vdpa device file. But in order to support other vdpa devices besides network interfaces (e.g. vdpa block devices) make this function a bit more generic. Signed-off-by: Jonathon Jongsma Reviewed-by: Peter Krempa --- src/qemu/qemu_command.c | 23 ++++++++++++++++++++++- src/qemu/qemu_command.h | 1 + src/qemu/qemu_interface.c | 23 ----------------------- src/qemu/qemu_interface.h | 2 -- tests/qemuhotplugmock.c | 4 ++-- tests/qemuxml2argvmock.c | 2 +- 6 files changed, 26 insertions(+), 29 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 778958700b..e84374b4cf 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8533,7 +8533,7 @@ qemuBuildInterfaceConnect(virDomainObj *vm, break; =20 case VIR_DOMAIN_NET_TYPE_VDPA: - if ((vdpafd =3D qemuInterfaceVDPAConnect(net)) < 0) + if ((vdpafd =3D qemuVDPAConnect(net->data.vdpa.devicepath)) < 0) return -1; =20 netpriv->vdpafd =3D qemuFDPassNew(net->info.alias, priv); @@ -10993,3 +10993,24 @@ qemuBuildStorageSourceChainAttachPrepareBlockdevTo= p(virStorageSource *top, =20 return g_steal_pointer(&data); } + + +/* qemuVDPAConnect: + * @devicepath: the path to the vdpa device + * + * returns: file descriptor of the vdpa device + */ +int +qemuVDPAConnect(const char *devicepath) +{ + int fd; + + if ((fd =3D open(devicepath, O_RDWR)) < 0) { + virReportSystemError(errno, + _("Unable to open '%1$s' for vdpa device"), + devicepath); + return -1; + } + + return fd; +} diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 55efa45601..341ec43f9a 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -248,3 +248,4 @@ qemuBuildTPMOpenBackendFDs(const char *tpmdev, =20 const char * qemuAudioDriverTypeToString(virDomainAudioType type); virDomainAudioType qemuAudioDriverTypeFromString(const char *str); +int qemuVDPAConnect(const char *devicepath) G_NO_INLINE; diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c index e875de48ee..8856bb95a8 100644 --- a/src/qemu/qemu_interface.c +++ b/src/qemu/qemu_interface.c @@ -648,29 +648,6 @@ qemuInterfaceBridgeConnect(virDomainDef *def, } =20 =20 -/* qemuInterfaceVDPAConnect: - * @net: pointer to the VM's interface description - * - * returns: file descriptor of the vdpa device - * - * Called *only* called if actualType is VIR_DOMAIN_NET_TYPE_VDPA - */ -int -qemuInterfaceVDPAConnect(virDomainNetDef *net) -{ - int fd; - - if ((fd =3D open(net->data.vdpa.devicepath, O_RDWR)) < 0) { - virReportSystemError(errno, - _("Unable to open '%1$s' for vdpa device"), - net->data.vdpa.devicepath); - return -1; - } - - return fd; -} - - /* * Returns: -1 on error, 0 on success. Populates net->privateData->slirp if * the slirp helper is needed. diff --git a/src/qemu/qemu_interface.h b/src/qemu/qemu_interface.h index d866beb184..6eed3e6bd7 100644 --- a/src/qemu/qemu_interface.h +++ b/src/qemu/qemu_interface.h @@ -55,5 +55,3 @@ int qemuInterfaceOpenVhostNet(virDomainObj *def, =20 int qemuInterfacePrepareSlirp(virQEMUDriver *driver, virDomainNetDef *net); - -int qemuInterfaceVDPAConnect(virDomainNetDef *net) G_NO_INLINE; diff --git a/tests/qemuhotplugmock.c b/tests/qemuhotplugmock.c index 89d287945a..dd7e2c67e0 100644 --- a/tests/qemuhotplugmock.c +++ b/tests/qemuhotplugmock.c @@ -18,8 +18,8 @@ =20 #include =20 +#include "qemu/qemu_command.h" #include "qemu/qemu_hotplug.h" -#include "qemu/qemu_interface.h" #include "qemu/qemu_process.h" #include "testutilsqemu.h" #include "conf/domain_conf.h" @@ -94,7 +94,7 @@ qemuProcessKillManagedPRDaemon(virDomainObj *vm G_GNUC_UN= USED) } =20 int -qemuInterfaceVDPAConnect(virDomainNetDef *net G_GNUC_UNUSED) +qemuVDPAConnect(const char *devicepath G_GNUC_UNUSED) { /* need a valid fd or sendmsg won't work. Just open /dev/null */ return open("/dev/null", O_RDONLY); diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c index 400dd5c020..52c44b2ed0 100644 --- a/tests/qemuxml2argvmock.c +++ b/tests/qemuxml2argvmock.c @@ -255,7 +255,7 @@ virNetDevBandwidthSetRootQDisc(const char *ifname G_GNU= C_UNUSED, =20 =20 int -qemuInterfaceVDPAConnect(virDomainNetDef *net G_GNUC_UNUSED) +qemuVDPAConnect(const char *devicepath G_GNUC_UNUSED) { if (fcntl(1732, F_GETFD) !=3D -1) abort(); --=20 2.41.0