From nobody Sun Apr 28 18:41:09 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1516873122384549.7150186334469; Thu, 25 Jan 2018 01:38:42 -0800 (PST) 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 73619780EE; Thu, 25 Jan 2018 09:38:41 +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 392F6600D1; Thu, 25 Jan 2018 09:38:41 +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 004A418033D9; Thu, 25 Jan 2018 09:38:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0P9cZ5T003125 for ; Thu, 25 Jan 2018 04:38:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id CA4BF50EDD; Thu, 25 Jan 2018 09:38:35 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE010600D1; Thu, 25 Jan 2018 09:38:33 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 25 Jan 2018 09:38:12 +0000 Message-Id: <20180125093825.5834-2-berrange@redhat.com> In-Reply-To: <20180125093825.5834-1-berrange@redhat.com> References: <20180125093825.5834-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 01/14] storage: extract storage file backend from main storage driver backend 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 25 Jan 2018 09:38:41 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The storage driver backends are serving the public storage pools API, while the storage file backends are serving the internal QEMU driver and / or libvirt utility code. To prep for moving this storage file backend framework into the utility code, split out the backend definitions. Signed-off-by: Daniel P. Berrange --- po/POTFILES.in | 1 + src/Makefile.am | 1 + src/storage/storage_backend.c | 66 --------------------- src/storage/storage_backend.h | 75 ----------------------- src/storage/storage_backend_fs.c | 7 ++- src/storage/storage_backend_gluster.c | 3 +- src/storage/storage_source.c | 2 +- src/storage/storage_source_backend.c | 108 ++++++++++++++++++++++++++++++= ++++ src/storage/storage_source_backend.h | 104 ++++++++++++++++++++++++++++++= ++ 9 files changed, 221 insertions(+), 146 deletions(-) create mode 100644 src/storage/storage_source_backend.c create mode 100644 src/storage/storage_source_backend.h diff --git a/po/POTFILES.in b/po/POTFILES.in index c1fa23427e..7145af7176 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -187,6 +187,7 @@ src/storage/storage_backend_vstorage.c src/storage/storage_backend_zfs.c src/storage/storage_driver.c src/storage/storage_source.c +src/storage/storage_source_backend.c src/storage/storage_util.c src/test/test_driver.c src/uml/uml_conf.c diff --git a/src/Makefile.am b/src/Makefile.am index 166c9a8e91..412eb10a4a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1057,6 +1057,7 @@ STORAGE_DRIVER_BACKEND_SOURCES =3D \ STORAGE_DRIVER_SOURCES =3D \ storage/storage_driver.h storage/storage_driver.c \ storage/storage_source.h storage/storage_source.c \ + storage/storage_source_backend.h storage/storage_source_backend.c \ $(STORAGE_DRIVER_BACKEND_SOURCES) \ storage/storage_util.h storage/storage_util.c =20 diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c index 5a8c4f7f6a..053f4ecf26 100644 --- a/src/storage/storage_backend.c +++ b/src/storage/storage_backend.c @@ -78,8 +78,6 @@ VIR_LOG_INIT("storage.storage_backend"); =20 static virStorageBackendPtr virStorageBackends[VIR_STORAGE_BACKENDS_MAX]; static size_t virStorageBackendsCount; -static virStorageFileBackendPtr virStorageFileBackends[VIR_STORAGE_BACKEND= S_MAX]; -static size_t virStorageFileBackendsCount; =20 #define STORAGE_BACKEND_MODULE_DIR LIBDIR "/libvirt/storage-backend" =20 @@ -179,27 +177,6 @@ virStorageBackendRegister(virStorageBackendPtr backend) } =20 =20 -int -virStorageBackendFileRegister(virStorageFileBackendPtr backend) -{ - VIR_DEBUG("Registering storage file backend '%s' protocol '%s'", - virStorageTypeToString(backend->type), - virStorageNetProtocolTypeToString(backend->protocol)); - - if (virStorageFileBackendsCount >=3D VIR_STORAGE_BACKENDS_MAX) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Too many drivers, cannot register storage file " - "backend '%s'"), - virStorageTypeToString(backend->type)); - return -1; - } - - virStorageFileBackends[virStorageFileBackendsCount] =3D backend; - virStorageFileBackendsCount++; - return 0; -} - - virStorageBackendPtr virStorageBackendForType(int type) { @@ -213,46 +190,3 @@ virStorageBackendForType(int type) type, NULLSTR(virStoragePoolTypeToString(type))); return NULL; } - - -virStorageFileBackendPtr -virStorageFileBackendForTypeInternal(int type, - int protocol, - bool report) -{ - size_t i; - - for (i =3D 0; i < virStorageFileBackendsCount; i++) { - if (virStorageFileBackends[i]->type =3D=3D type) { - if (type =3D=3D VIR_STORAGE_TYPE_NETWORK && - virStorageFileBackends[i]->protocol !=3D protocol) - continue; - - return virStorageFileBackends[i]; - } - } - - if (!report) - return NULL; - - if (type =3D=3D VIR_STORAGE_TYPE_NETWORK) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("missing storage backend for network files " - "using %s protocol"), - virStorageNetProtocolTypeToString(protocol)); - } else { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("missing storage backend for '%s' storage"), - virStorageTypeToString(type)); - } - - return NULL; -} - - -virStorageFileBackendPtr -virStorageFileBackendForType(int type, - int protocol) -{ - return virStorageFileBackendForTypeInternal(type, protocol, true); -} diff --git a/src/storage/storage_backend.h b/src/storage/storage_backend.h index 193cf134d6..f9aa4cd26b 100644 --- a/src/storage/storage_backend.h +++ b/src/storage/storage_backend.h @@ -125,83 +125,8 @@ struct _virStorageBackend { =20 virStorageBackendPtr virStorageBackendForType(int type); =20 -/* ------- virStorageFile backends ------------ */ -typedef struct _virStorageFileBackend virStorageFileBackend; -typedef virStorageFileBackend *virStorageFileBackendPtr; - -struct _virStorageDriverData { - virStorageFileBackendPtr backend; - void *priv; - - uid_t uid; - gid_t gid; -}; - -typedef int -(*virStorageFileBackendInit)(virStorageSourcePtr src); - -typedef void -(*virStorageFileBackendDeinit)(virStorageSourcePtr src); - -typedef int -(*virStorageFileBackendCreate)(virStorageSourcePtr src); - -typedef int -(*virStorageFileBackendUnlink)(virStorageSourcePtr src); - -typedef int -(*virStorageFileBackendStat)(virStorageSourcePtr src, - struct stat *st); - -typedef ssize_t -(*virStorageFileBackendRead)(virStorageSourcePtr src, - size_t offset, - size_t len, - char **buf); - -typedef const char * -(*virStorageFileBackendGetUniqueIdentifier)(virStorageSourcePtr src); - -typedef int -(*virStorageFileBackendAccess)(virStorageSourcePtr src, - int mode); - -typedef int -(*virStorageFileBackendChown)(const virStorageSource *src, - uid_t uid, - gid_t gid); - -virStorageFileBackendPtr virStorageFileBackendForType(int type, int protoc= ol); -virStorageFileBackendPtr virStorageFileBackendForTypeInternal(int type, - int protocol, - bool report); - - -struct _virStorageFileBackend { - int type; - int protocol; - - /* All storage file callbacks may be omitted if not implemented */ - - /* The following group of callbacks is expected to set a libvirt - * error on failure. */ - virStorageFileBackendInit backendInit; - virStorageFileBackendDeinit backendDeinit; - virStorageFileBackendRead storageFileRead; - virStorageFileBackendGetUniqueIdentifier storageFileGetUniqueIdentifie= r; - - /* The following group of callbacks is expected to set errno - * and return -1 on error. No libvirt error shall be reported */ - virStorageFileBackendCreate storageFileCreate; - virStorageFileBackendUnlink storageFileUnlink; - virStorageFileBackendStat storageFileStat; - virStorageFileBackendAccess storageFileAccess; - virStorageFileBackendChown storageFileChown; -}; - int virStorageBackendDriversRegister(bool allmodules); =20 int virStorageBackendRegister(virStorageBackendPtr backend); -int virStorageBackendFileRegister(virStorageFileBackendPtr backend); =20 #endif /* __VIR_STORAGE_BACKEND_H__ */ diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend= _fs.c index f54759983c..a1531b8493 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -37,6 +37,7 @@ =20 #include "virerror.h" #include "storage_backend_fs.h" +#include "storage_source_backend.h" #include "storage_util.h" #include "storage_conf.h" #include "virstoragefile.h" @@ -918,13 +919,13 @@ virStorageBackendFsRegister(void) return -1; #endif /* WITH_STORAGE_FS */ =20 - if (virStorageBackendFileRegister(&virStorageFileBackendFile) < 0) + if (virStorageFileBackendRegister(&virStorageFileBackendFile) < 0) return -1; =20 - if (virStorageBackendFileRegister(&virStorageFileBackendBlock) < 0) + if (virStorageFileBackendRegister(&virStorageFileBackendBlock) < 0) return -1; =20 - if (virStorageBackendFileRegister(&virStorageFileBackendDir) < 0) + if (virStorageFileBackendRegister(&virStorageFileBackendDir) < 0) return -1; =20 return 0; diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_ba= ckend_gluster.c index 5eea84f16e..c32267875d 100644 --- a/src/storage/storage_backend_gluster.c +++ b/src/storage/storage_backend_gluster.c @@ -24,6 +24,7 @@ #include =20 #include "storage_backend_gluster.h" +#include "storage_source_backend.h" #include "storage_conf.h" #include "viralloc.h" #include "virerror.h" @@ -869,7 +870,7 @@ virStorageBackendGlusterRegister(void) if (virStorageBackendRegister(&virStorageBackendGluster) < 0) return -1; =20 - if (virStorageBackendFileRegister(&virStorageFileBackendGluster) < 0) + if (virStorageFileBackendRegister(&virStorageFileBackendGluster) < 0) return -1; =20 return 0; diff --git a/src/storage/storage_source.c b/src/storage/storage_source.c index 170ab755b7..a5eefe5032 100644 --- a/src/storage/storage_source.c +++ b/src/storage/storage_source.c @@ -26,7 +26,7 @@ =20 #include "virerror.h" #include "storage_source.h" -#include "storage_backend.h" +#include "storage_source_backend.h" #include "viralloc.h" #include "virlog.h" #include "virstring.h" diff --git a/src/storage/storage_source_backend.c b/src/storage/storage_sou= rce_backend.c new file mode 100644 index 0000000000..e093c04989 --- /dev/null +++ b/src/storage/storage_source_backend.c @@ -0,0 +1,108 @@ +/* + * storage_source_backend.c: internal storage source backend contract + * + * Copyright (C) 2007-2018 Red Hat, Inc. + * Copyright (C) 2007-2008 Daniel P. Berrange + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + * + * Author: Daniel P. Berrange + */ + +#include + +#include +#include + +#include "datatypes.h" +#include "virerror.h" +#include "viralloc.h" +#include "internal.h" +#include "storage_source_backend.h" +#include "virlog.h" +#include "virfile.h" +#include "configmake.h" + +#define VIR_FROM_THIS VIR_FROM_STORAGE + +VIR_LOG_INIT("storage.storage_source_backend"); + +#define VIR_STORAGE_BACKENDS_MAX 20 + +static virStorageFileBackendPtr virStorageFileBackends[VIR_STORAGE_BACKEND= S_MAX]; +static size_t virStorageFileBackendsCount; + + +int +virStorageFileBackendRegister(virStorageFileBackendPtr backend) +{ + VIR_DEBUG("Registering storage file backend '%s' protocol '%s'", + virStorageTypeToString(backend->type), + virStorageNetProtocolTypeToString(backend->protocol)); + + if (virStorageFileBackendsCount >=3D VIR_STORAGE_BACKENDS_MAX) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Too many drivers, cannot register storage file " + "backend '%s'"), + virStorageTypeToString(backend->type)); + return -1; + } + + virStorageFileBackends[virStorageFileBackendsCount] =3D backend; + virStorageFileBackendsCount++; + return 0; +} + +virStorageFileBackendPtr +virStorageFileBackendForTypeInternal(int type, + int protocol, + bool report) +{ + size_t i; + + for (i =3D 0; i < virStorageFileBackendsCount; i++) { + if (virStorageFileBackends[i]->type =3D=3D type) { + if (type =3D=3D VIR_STORAGE_TYPE_NETWORK && + virStorageFileBackends[i]->protocol !=3D protocol) + continue; + + return virStorageFileBackends[i]; + } + } + + if (!report) + return NULL; + + if (type =3D=3D VIR_STORAGE_TYPE_NETWORK) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("missing storage backend for network files " + "using %s protocol"), + virStorageNetProtocolTypeToString(protocol)); + } else { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("missing storage backend for '%s' storage"), + virStorageTypeToString(type)); + } + + return NULL; +} + + +virStorageFileBackendPtr +virStorageFileBackendForType(int type, + int protocol) +{ + return virStorageFileBackendForTypeInternal(type, protocol, true); +} diff --git a/src/storage/storage_source_backend.h b/src/storage/storage_sou= rce_backend.h new file mode 100644 index 0000000000..8288bebb1f --- /dev/null +++ b/src/storage/storage_source_backend.h @@ -0,0 +1,104 @@ +/* + * storage_source_backend.h: internal storage source backend contract + * + * Copyright (C) 2007-2018 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#ifndef __VIR_STORAGE_SOURCE_BACKEND_H__ +# define __VIR_STORAGE_SOURCE_BACKEND_H__ + +# include + +# include "virstoragefile.h" + +/* ------- virStorageFile backends ------------ */ +typedef struct _virStorageFileBackend virStorageFileBackend; +typedef virStorageFileBackend *virStorageFileBackendPtr; + +struct _virStorageDriverData { + virStorageFileBackendPtr backend; + void *priv; + + uid_t uid; + gid_t gid; +}; + +typedef int +(*virStorageFileBackendInit)(virStorageSourcePtr src); + +typedef void +(*virStorageFileBackendDeinit)(virStorageSourcePtr src); + +typedef int +(*virStorageFileBackendCreate)(virStorageSourcePtr src); + +typedef int +(*virStorageFileBackendUnlink)(virStorageSourcePtr src); + +typedef int +(*virStorageFileBackendStat)(virStorageSourcePtr src, + struct stat *st); + +typedef ssize_t +(*virStorageFileBackendRead)(virStorageSourcePtr src, + size_t offset, + size_t len, + char **buf); + +typedef const char * +(*virStorageFileBackendGetUniqueIdentifier)(virStorageSourcePtr src); + +typedef int +(*virStorageFileBackendAccess)(virStorageSourcePtr src, + int mode); + +typedef int +(*virStorageFileBackendChown)(const virStorageSource *src, + uid_t uid, + gid_t gid); + +virStorageFileBackendPtr virStorageFileBackendForType(int type, int protoc= ol); +virStorageFileBackendPtr virStorageFileBackendForTypeInternal(int type, + int protocol, + bool report); + + +struct _virStorageFileBackend { + int type; + int protocol; + + /* All storage file callbacks may be omitted if not implemented */ + + /* The following group of callbacks is expected to set a libvirt + * error on failure. */ + virStorageFileBackendInit backendInit; + virStorageFileBackendDeinit backendDeinit; + virStorageFileBackendRead storageFileRead; + virStorageFileBackendGetUniqueIdentifier storageFileGetUniqueIdentifie= r; + + /* The following group of callbacks is expected to set errno + * and return -1 on error. No libvirt error shall be reported */ + virStorageFileBackendCreate storageFileCreate; + virStorageFileBackendUnlink storageFileUnlink; + virStorageFileBackendStat storageFileStat; + virStorageFileBackendAccess storageFileAccess; + virStorageFileBackendChown storageFileChown; +}; + +int virStorageFileBackendRegister(virStorageFileBackendPtr backend); + +#endif /* __VIR_STORAGE_BACKEND_H__ */ --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 18:41:09 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1516873121619499.8101777031171; Thu, 25 Jan 2018 01:38:41 -0800 (PST) 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 91FF113AAB; Thu, 25 Jan 2018 09:38:40 +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 68E902C317; Thu, 25 Jan 2018 09:38:40 +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 0A6B15FBDA; Thu, 25 Jan 2018 09:38:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0P9cc4L003147 for ; Thu, 25 Jan 2018 04:38:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id DA5436056B; Thu, 25 Jan 2018 09:38:38 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 711A7600D1; Thu, 25 Jan 2018 09:38:36 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 25 Jan 2018 09:38:13 +0000 Message-Id: <20180125093825.5834-3-berrange@redhat.com> In-Reply-To: <20180125093825.5834-1-berrange@redhat.com> References: <20180125093825.5834-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 02/14] storage: move storage file backend framework into util directory 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]); Thu, 25 Jan 2018 09:38:41 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The QEMU driver loadable module needs to be able to resolve all ELF symbols it references against libvirt.so. Some of its symbols can only be resolved against the storage_driver.so loadable module which creates a hard dependancy between them. By moving the storage file backend framework into the util directory, this gets included directly in the libvirt.so library. The actual backend implementations are still done as loadable modules, so this doesn't re-add deps on gluster libraries. Signed-off-by: Daniel P. Berrange --- po/POTFILES.in | 3 +- src/Makefile.am | 3 +- src/libvirt_private.syms | 19 + src/qemu/qemu_domain.c | 1 - src/qemu/qemu_driver.c | 1 - src/security/virt-aa-helper.c | 2 - src/storage/storage_backend_fs.c | 3 +- src/storage/storage_backend_gluster.c | 3 +- src/storage/storage_source.c | 645 -----------------= ---- src/storage/storage_source.h | 59 -- src/util/virstoragefile.c | 609 +++++++++++++++++= +- src/util/virstoragefile.h | 32 + .../virstoragefilebackend.c} | 4 +- .../virstoragefilebackend.h} | 8 +- tests/virstoragetest.c | 1 - 15 files changed, 669 insertions(+), 724 deletions(-) delete mode 100644 src/storage/storage_source.c delete mode 100644 src/storage/storage_source.h rename src/{storage/storage_source_backend.c =3D> util/virstoragefilebacke= nd.c} (96%) rename src/{storage/storage_source_backend.h =3D> util/virstoragefilebacke= nd.h} (94%) diff --git a/po/POTFILES.in b/po/POTFILES.in index 7145af7176..5d88c04de2 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -186,8 +186,6 @@ src/storage/storage_backend_sheepdog.c src/storage/storage_backend_vstorage.c src/storage/storage_backend_zfs.c src/storage/storage_driver.c -src/storage/storage_source.c -src/storage/storage_source_backend.c src/storage/storage_util.c src/test/test_driver.c src/uml/uml_conf.c @@ -262,6 +260,7 @@ src/util/virsexpr.c src/util/virsocketaddr.c src/util/virstorageencryption.c src/util/virstoragefile.c +src/util/virstoragefilebackend.c src/util/virstring.c src/util/virsysinfo.c src/util/virthreadjob.c diff --git a/src/Makefile.am b/src/Makefile.am index 412eb10a4a..6b4db22937 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -178,6 +178,7 @@ UTIL_SOURCES =3D \ util/virsocketaddr.h util/virsocketaddr.c \ util/virstorageencryption.c util/virstorageencryption.h \ util/virstoragefile.c util/virstoragefile.h \ + util/virstoragefilebackend.c util/virstoragefilebackend.h \ util/virstring.h util/virstring.c \ util/virsysinfo.c util/virsysinfo.h util/virsysinfopriv.h \ util/virsystemd.c util/virsystemd.h util/virsystemdpriv.h \ @@ -1056,8 +1057,6 @@ STORAGE_DRIVER_BACKEND_SOURCES =3D \ =20 STORAGE_DRIVER_SOURCES =3D \ storage/storage_driver.h storage/storage_driver.c \ - storage/storage_source.h storage/storage_source.c \ - storage/storage_source_backend.h storage/storage_source_backend.c \ $(STORAGE_DRIVER_BACKEND_SOURCES) \ storage/storage_util.h storage/storage_util.c =20 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index bc8cc1fba9..3d8ed0b9de 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2691,24 +2691,39 @@ virStorageAuthDefCopy; virStorageAuthDefFormat; virStorageAuthDefFree; virStorageAuthDefParse; +virStorageFileAccess; virStorageFileCanonicalizePath; virStorageFileChainGetBroken; virStorageFileChainLookup; +virStorageFileChown; +virStorageFileCreate; +virStorageFileDeinit; virStorageFileFeatureTypeFromString; virStorageFileFeatureTypeToString; virStorageFileFormatTypeFromString; virStorageFileFormatTypeToString; +virStorageFileGetBackingStoreStr; virStorageFileGetLVMKey; +virStorageFileGetMetadata; virStorageFileGetMetadataFromBuf; virStorageFileGetMetadataFromFD; virStorageFileGetMetadataInternal; virStorageFileGetRelativeBackingPath; virStorageFileGetSCSIKey; +virStorageFileGetUniqueIdentifier; +virStorageFileInit; +virStorageFileInitAs; virStorageFileIsClusterFS; virStorageFileParseBackingStoreStr; virStorageFileParseChainIndex; virStorageFileProbeFormat; +virStorageFileRead; +virStorageFileReportBrokenChain; virStorageFileResize; +virStorageFileStat; +virStorageFileSupportsAccess; +virStorageFileSupportsSecurityDriver; +virStorageFileUnlink; virStorageIsFile; virStorageIsRelative; virStorageNetHostDefClear; @@ -2747,6 +2762,10 @@ virStorageTypeFromString; virStorageTypeToString; =20 =20 +# util/virstoragefilebackend.h +virStorageFileBackendRegister; + + # util/virstring.h virArgvToString; virAsprintfInternal; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6b4bd3cca0..38ed4bec5c 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -56,7 +56,6 @@ #include "locking/domain_lock.h" =20 #include "storage/storage_driver.h" -#include "storage/storage_source.h" =20 #ifdef MAJOR_IN_MKDEV # include diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index a203c9297a..28ca4c09cc 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -100,7 +100,6 @@ #include "viraccessapicheck.h" #include "viraccessapicheckqemu.h" #include "storage/storage_driver.h" -#include "storage/storage_source.h" #include "virhostdev.h" #include "domain_capabilities.h" #include "vircgroup.h" diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index f7ccae0b02..d5f3e858fa 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -57,8 +57,6 @@ #include "virgettext.h" #include "virhostdev.h" =20 -#include "storage/storage_source.h" - #define VIR_FROM_THIS VIR_FROM_SECURITY =20 static char *progname; diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend= _fs.c index a1531b8493..71f9f8c620 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -37,10 +37,9 @@ =20 #include "virerror.h" #include "storage_backend_fs.h" -#include "storage_source_backend.h" #include "storage_util.h" #include "storage_conf.h" -#include "virstoragefile.h" +#include "virstoragefilebackend.h" #include "vircommand.h" #include "viralloc.h" #include "virxml.h" diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_ba= ckend_gluster.c index c32267875d..c63118ae38 100644 --- a/src/storage/storage_backend_gluster.c +++ b/src/storage/storage_backend_gluster.c @@ -24,12 +24,11 @@ #include =20 #include "storage_backend_gluster.h" -#include "storage_source_backend.h" #include "storage_conf.h" #include "viralloc.h" #include "virerror.h" #include "virlog.h" -#include "virstoragefile.h" +#include "virstoragefilebackend.h" #include "virstring.h" #include "viruri.h" #include "storage_util.h" diff --git a/src/storage/storage_source.c b/src/storage/storage_source.c deleted file mode 100644 index a5eefe5032..0000000000 --- a/src/storage/storage_source.c +++ /dev/null @@ -1,645 +0,0 @@ -/* - * storage_source.c: Storage source object accessors to real storage - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * . - */ - -#include - -#include -#include - -#include -#include - -#include "virerror.h" -#include "storage_source.h" -#include "storage_source_backend.h" -#include "viralloc.h" -#include "virlog.h" -#include "virstring.h" -#include "virhash.h" - -#define VIR_FROM_THIS VIR_FROM_STORAGE - -VIR_LOG_INIT("storage.storage_source"); - - -static bool -virStorageFileIsInitialized(const virStorageSource *src) -{ - return src && src->drv; -} - - -static virStorageFileBackendPtr -virStorageFileGetBackendForSupportCheck(const virStorageSource *src) -{ - int actualType; - - if (!src) - return NULL; - - if (src->drv) - return src->drv->backend; - - actualType =3D virStorageSourceGetActualType(src); - - return virStorageFileBackendForTypeInternal(actualType, src->protocol,= false); -} - - -static bool -virStorageFileSupportsBackingChainTraversal(virStorageSourcePtr src) -{ - virStorageFileBackendPtr backend; - - if (!(backend =3D virStorageFileGetBackendForSupportCheck(src))) - return false; - - return backend->storageFileGetUniqueIdentifier && - backend->storageFileRead && - backend->storageFileAccess; -} - - -/** - * virStorageFileSupportsSecurityDriver: - * - * @src: a storage file structure - * - * Check if a storage file supports operations needed by the security - * driver to perform labelling - */ -bool -virStorageFileSupportsSecurityDriver(const virStorageSource *src) -{ - virStorageFileBackendPtr backend; - - if (!(backend =3D virStorageFileGetBackendForSupportCheck(src))) - return false; - - return !!backend->storageFileChown; -} - - -/** - * virStorageFileSupportsAccess: - * - * @src: a storage file structure - * - * Check if a storage file supports checking if the storage source is acce= ssible - * for the given vm. - */ -bool -virStorageFileSupportsAccess(const virStorageSource *src) -{ - virStorageFileBackendPtr backend; - - if (!(backend =3D virStorageFileGetBackendForSupportCheck(src))) - return false; - - return !!backend->storageFileAccess; -} - - -void -virStorageFileDeinit(virStorageSourcePtr src) -{ - if (!virStorageFileIsInitialized(src)) - return; - - if (src->drv->backend && - src->drv->backend->backendDeinit) - src->drv->backend->backendDeinit(src); - - VIR_FREE(src->drv); -} - - -/** - * virStorageFileInitAs: - * - * @src: storage source definition - * @uid: uid used to access the file, or -1 for current uid - * @gid: gid used to access the file, or -1 for current gid - * - * Initialize a storage source to be used with storage driver. Use the pro= vided - * uid and gid if possible for the operations. - * - * Returns 0 if the storage file was successfully initialized, -1 if the - * initialization failed. Libvirt error is reported. - */ -int -virStorageFileInitAs(virStorageSourcePtr src, - uid_t uid, gid_t gid) -{ - int actualType =3D virStorageSourceGetActualType(src); - if (VIR_ALLOC(src->drv) < 0) - return -1; - - if (uid =3D=3D (uid_t) -1) - src->drv->uid =3D geteuid(); - else - src->drv->uid =3D uid; - - if (gid =3D=3D (gid_t) -1) - src->drv->gid =3D getegid(); - else - src->drv->gid =3D gid; - - if (!(src->drv->backend =3D virStorageFileBackendForType(actualType, - src->protocol))) - goto error; - - if (src->drv->backend->backendInit && - src->drv->backend->backendInit(src) < 0) - goto error; - - return 0; - - error: - VIR_FREE(src->drv); - return -1; -} - - -/** - * virStorageFileInit: - * - * See virStorageFileInitAs. The file is initialized to be accessed by the - * current user. - */ -int -virStorageFileInit(virStorageSourcePtr src) -{ - return virStorageFileInitAs(src, -1, -1); -} - - -/** - * virStorageFileCreate: Creates an empty storage file via storage driver - * - * @src: file structure pointing to the file - * - * Returns 0 on success, -2 if the function isn't supported by the backend, - * -1 on other failure. Errno is set in case of failure. - */ -int -virStorageFileCreate(virStorageSourcePtr src) -{ - int ret; - - if (!virStorageFileIsInitialized(src) || - !src->drv->backend->storageFileCreate) { - errno =3D ENOSYS; - return -2; - } - - ret =3D src->drv->backend->storageFileCreate(src); - - VIR_DEBUG("created storage file %p: ret=3D%d, errno=3D%d", - src, ret, errno); - - return ret; -} - - -/** - * virStorageFileUnlink: Unlink storage file via storage driver - * - * @src: file structure pointing to the file - * - * Unlinks the file described by the @file structure. - * - * Returns 0 on success, -2 if the function isn't supported by the backend, - * -1 on other failure. Errno is set in case of failure. - */ -int -virStorageFileUnlink(virStorageSourcePtr src) -{ - int ret; - - if (!virStorageFileIsInitialized(src) || - !src->drv->backend->storageFileUnlink) { - errno =3D ENOSYS; - return -2; - } - - ret =3D src->drv->backend->storageFileUnlink(src); - - VIR_DEBUG("unlinked storage file %p: ret=3D%d, errno=3D%d", - src, ret, errno); - - return ret; -} - - -/** - * virStorageFileStat: returns stat struct of a file via storage driver - * - * @src: file structure pointing to the file - * @stat: stat structure to return data - * - * Returns 0 on success, -2 if the function isn't supported by the backend, - * -1 on other failure. Errno is set in case of failure. -*/ -int -virStorageFileStat(virStorageSourcePtr src, - struct stat *st) -{ - int ret; - - if (!virStorageFileIsInitialized(src) || - !src->drv->backend->storageFileStat) { - errno =3D ENOSYS; - return -2; - } - - ret =3D src->drv->backend->storageFileStat(src, st); - - VIR_DEBUG("stat of storage file %p: ret=3D%d, errno=3D%d", - src, ret, errno); - - return ret; -} - - -/** - * virStorageFileRead: read bytes from a file into a buffer - * - * @src: file structure pointing to the file - * @offset: number of bytes to skip in the storage file - * @len: maximum number of bytes read from the storage file - * @buf: buffer to read the data into. (buffer shall be freed by caller) - * - * Returns the count of bytes read on success and -1 on failure, -2 if the - * function isn't supported by the backend. - * Libvirt error is reported on failure. - */ -ssize_t -virStorageFileRead(virStorageSourcePtr src, - size_t offset, - size_t len, - char **buf) -{ - ssize_t ret; - - if (!virStorageFileIsInitialized(src)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("storage file backend not initialized")); - return -1; - } - - if (!src->drv->backend->storageFileRead) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("storage file reading is not supported for " - "storage type %s (protocol: %s)"), - virStorageTypeToString(src->type), - virStorageNetProtocolTypeToString(src->protocol)); - return -2; - } - - ret =3D src->drv->backend->storageFileRead(src, offset, len, buf); - - VIR_DEBUG("read '%zd' bytes from storage '%p' starting at offset '%zu'= ", - ret, src, offset); - - return ret; -} - - -/* - * virStorageFileGetUniqueIdentifier: Get a unique string describing the v= olume - * - * @src: file structure pointing to the file - * - * Returns a string uniquely describing a single volume (canonical path). - * The string shall not be freed and is valid until the storage file is - * deinitialized. Returns NULL on error and sets a libvirt error code */ -const char * -virStorageFileGetUniqueIdentifier(virStorageSourcePtr src) -{ - if (!virStorageFileIsInitialized(src)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("storage file backend not initialized")); - return NULL; - } - - if (!src->drv->backend->storageFileGetUniqueIdentifier) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unique storage file identifier not implemented f= or " - "storage type %s (protocol: %s)'"), - virStorageTypeToString(src->type), - virStorageNetProtocolTypeToString(src->protocol)); - return NULL; - } - - return src->drv->backend->storageFileGetUniqueIdentifier(src); -} - - -/** - * virStorageFileAccess: Check accessibility of a storage file - * - * @src: storage file to check access permissions - * @mode: accessibility check options (see man 2 access) - * - * Returns 0 on success, -1 on error and sets errno. No libvirt - * error is reported. Returns -2 if the operation isn't supported - * by libvirt storage backend. - */ -int -virStorageFileAccess(virStorageSourcePtr src, - int mode) -{ - if (!virStorageFileIsInitialized(src) || - !src->drv->backend->storageFileAccess) { - errno =3D ENOSYS; - return -2; - } - - return src->drv->backend->storageFileAccess(src, mode); -} - - -/** - * virStorageFileChown: Change owner of a storage file - * - * @src: storage file to change owner of - * @uid: new owner id - * @gid: new group id - * - * Returns 0 on success, -1 on error and sets errno. No libvirt - * error is reported. Returns -2 if the operation isn't supported - * by libvirt storage backend. - */ -int -virStorageFileChown(const virStorageSource *src, - uid_t uid, - gid_t gid) -{ - if (!virStorageFileIsInitialized(src) || - !src->drv->backend->storageFileChown) { - errno =3D ENOSYS; - return -2; - } - - VIR_DEBUG("chown of storage file %p to %u:%u", - src, (unsigned int)uid, (unsigned int)gid); - - return src->drv->backend->storageFileChown(src, uid, gid); -} - - -/** - * virStorageFileReportBrokenChain: - * - * @errcode: errno when accessing @src - * @src: inaccessible file in the backing chain of @parent - * @parent: root virStorageSource being checked - * - * Reports the correct error message if @src is missing in the backing cha= in - * for @parent. - */ -void -virStorageFileReportBrokenChain(int errcode, - virStorageSourcePtr src, - virStorageSourcePtr parent) -{ - - if (src->drv) { - unsigned int access_user =3D src->drv->uid; - unsigned int access_group =3D src->drv->gid; - - if (src =3D=3D parent) { - virReportSystemError(errcode, - _("Cannot access storage file '%s' " - "(as uid:%u, gid:%u)"), - src->path, access_user, access_group); - } else { - virReportSystemError(errcode, - _("Cannot access backing file '%s' " - "of storage file '%s' (as uid:%u, gid:%= u)"), - src->path, parent->path, access_user, acc= ess_group); - } - } else { - if (src =3D=3D parent) { - virReportSystemError(errcode, - _("Cannot access storage file '%s'"), - src->path); - } else { - virReportSystemError(errcode, - _("Cannot access backing file '%s' " - "of storage file '%s'"), - src->path, parent->path); - } - } -} - - -/* Recursive workhorse for virStorageFileGetMetadata. */ -static int -virStorageFileGetMetadataRecurse(virStorageSourcePtr src, - virStorageSourcePtr parent, - uid_t uid, gid_t gid, - bool allow_probe, - bool report_broken, - virHashTablePtr cycle, - unsigned int depth) -{ - int ret =3D -1; - const char *uniqueName; - char *buf =3D NULL; - ssize_t headerLen; - virStorageSourcePtr backingStore =3D NULL; - int backingFormat; - - VIR_DEBUG("path=3D%s format=3D%d uid=3D%u gid=3D%u probe=3D%d", - src->path, src->format, - (unsigned int)uid, (unsigned int)gid, allow_probe); - - /* exit if we can't load information about the current image */ - if (!virStorageFileSupportsBackingChainTraversal(src)) - return 0; - - if (virStorageFileInitAs(src, uid, gid) < 0) - return -1; - - if (virStorageFileAccess(src, F_OK) < 0) { - virStorageFileReportBrokenChain(errno, src, parent); - goto cleanup; - } - - if (!(uniqueName =3D virStorageFileGetUniqueIdentifier(src))) - goto cleanup; - - if (virHashLookup(cycle, uniqueName)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("backing store for %s (%s) is self-referential"), - src->path, uniqueName); - goto cleanup; - } - - if (virHashAddEntry(cycle, uniqueName, (void *)1) < 0) - goto cleanup; - - if ((headerLen =3D virStorageFileRead(src, 0, VIR_STORAGE_MAX_HEADER, - &buf)) < 0) - goto cleanup; - - if (virStorageFileGetMetadataInternal(src, buf, headerLen, - &backingFormat) < 0) - goto cleanup; - - if (src->backingStoreRaw) { - if (!(backingStore =3D virStorageSourceNewFromBacking(src))) - goto cleanup; - - if (backingFormat =3D=3D VIR_STORAGE_FILE_AUTO && !allow_probe) - backingStore->format =3D VIR_STORAGE_FILE_RAW; - else if (backingFormat =3D=3D VIR_STORAGE_FILE_AUTO_SAFE) - backingStore->format =3D VIR_STORAGE_FILE_AUTO; - else - backingStore->format =3D backingFormat; - - if ((ret =3D virStorageFileGetMetadataRecurse(backingStore, parent, - uid, gid, - allow_probe, report_br= oken, - cycle, depth + 1)) < 0= ) { - if (report_broken) - goto cleanup; - - /* if we fail somewhere midway, just accept and return a - * broken chain */ - ret =3D 0; - goto cleanup; - } - } else { - /* add terminator */ - if (VIR_ALLOC(backingStore) < 0) - goto cleanup; - } - - src->backingStore =3D backingStore; - backingStore =3D NULL; - ret =3D 0; - - cleanup: - if (virStorageSourceHasBacking(src)) - src->backingStore->id =3D depth; - VIR_FREE(buf); - virStorageFileDeinit(src); - virStorageSourceFree(backingStore); - return ret; -} - - -/** - * virStorageFileGetMetadata: - * - * Extract metadata about the storage volume with the specified - * image format. If image format is VIR_STORAGE_FILE_AUTO, it - * will probe to automatically identify the format. Recurses through - * the entire chain. - * - * Open files using UID and GID (or pass -1 for the current user/group). - * Treat any backing files without explicit type as raw, unless ALLOW_PROB= E. - * - * Callers are advised never to use VIR_STORAGE_FILE_AUTO as a - * format, since a malicious guest can turn a raw file into any - * other non-raw format at will. - * - * If @report_broken is true, the whole function fails with a possibly sane - * error instead of just returning a broken chain. - * - * Caller MUST free result after use via virStorageSourceFree. - */ -int -virStorageFileGetMetadata(virStorageSourcePtr src, - uid_t uid, gid_t gid, - bool allow_probe, - bool report_broken) -{ - VIR_DEBUG("path=3D%s format=3D%d uid=3D%u gid=3D%u probe=3D%d, report_= broken=3D%d", - src->path, src->format, (unsigned int)uid, (unsigned int)gid, - allow_probe, report_broken); - - virHashTablePtr cycle =3D NULL; - virStorageType actualType =3D virStorageSourceGetActualType(src); - int ret =3D -1; - - if (!(cycle =3D virHashCreate(5, NULL))) - return -1; - - if (src->format <=3D VIR_STORAGE_FILE_NONE) { - if (actualType =3D=3D VIR_STORAGE_TYPE_DIR) - src->format =3D VIR_STORAGE_FILE_DIR; - else if (allow_probe) - src->format =3D VIR_STORAGE_FILE_AUTO; - else - src->format =3D VIR_STORAGE_FILE_RAW; - } - - ret =3D virStorageFileGetMetadataRecurse(src, src, uid, gid, - allow_probe, report_broken, cyc= le, 1); - - virHashFree(cycle); - return ret; -} - - -/** - * virStorageFileGetBackingStoreStr: - * @src: storage object - * - * Extracts the backing store string as stored in the storage volume descr= ibed - * by @src and returns it to the user. Caller is responsible for freeing i= t. - * In case when the string can't be retrieved or does not exist NULL is - * returned. - */ -char * -virStorageFileGetBackingStoreStr(virStorageSourcePtr src) -{ - virStorageSourcePtr tmp =3D NULL; - char *buf =3D NULL; - ssize_t headerLen; - char *ret =3D NULL; - - /* exit if we can't load information about the current image */ - if (!virStorageFileSupportsBackingChainTraversal(src)) - return NULL; - - if (virStorageFileAccess(src, F_OK) < 0) - return NULL; - - if ((headerLen =3D virStorageFileRead(src, 0, VIR_STORAGE_MAX_HEADER, - &buf)) < 0) - return NULL; - - if (!(tmp =3D virStorageSourceCopy(src, false))) - goto cleanup; - - if (virStorageFileGetMetadataInternal(tmp, buf, headerLen, NULL) < 0) - goto cleanup; - - VIR_STEAL_PTR(ret, tmp->backingStoreRaw); - - cleanup: - VIR_FREE(buf); - virStorageSourceFree(tmp); - - return ret; -} diff --git a/src/storage/storage_source.h b/src/storage/storage_source.h deleted file mode 100644 index 0640c138ed..0000000000 --- a/src/storage/storage_source.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * storage_source.h: Storage source accessors to real storaget - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * . - */ - -#ifndef __VIR_STORAGE_SOURCE_H__ -# define __VIR_STORAGE_SOURCE_H__ - -# include - -# include "virstoragefile.h" - -int virStorageFileInit(virStorageSourcePtr src); -int virStorageFileInitAs(virStorageSourcePtr src, - uid_t uid, gid_t gid); -void virStorageFileDeinit(virStorageSourcePtr src); - -int virStorageFileCreate(virStorageSourcePtr src); -int virStorageFileUnlink(virStorageSourcePtr src); -int virStorageFileStat(virStorageSourcePtr src, - struct stat *stat); -ssize_t virStorageFileRead(virStorageSourcePtr src, - size_t offset, - size_t len, - char **buf); -const char *virStorageFileGetUniqueIdentifier(virStorageSourcePtr src); -int virStorageFileAccess(virStorageSourcePtr src, int mode); -int virStorageFileChown(const virStorageSource *src, uid_t uid, gid_t gid); - -bool virStorageFileSupportsSecurityDriver(const virStorageSource *src); -bool virStorageFileSupportsAccess(const virStorageSource *src); - -int virStorageFileGetMetadata(virStorageSourcePtr src, - uid_t uid, gid_t gid, - bool allow_probe, - bool report_broken) - ATTRIBUTE_NONNULL(1); - -char *virStorageFileGetBackingStoreStr(virStorageSourcePtr src) - ATTRIBUTE_NONNULL(1); - -void virStorageFileReportBrokenChain(int errcode, - virStorageSourcePtr src, - virStorageSourcePtr parent); - -#endif /* __VIR_STORAGE_SOURCE_H__ */ diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 5780180a94..56e20f834c 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -22,7 +22,7 @@ */ =20 #include -#include "virstoragefile.h" +#include "virstoragefilebackend.h" =20 #include #include @@ -4106,3 +4106,610 @@ virStorageSourcePrivateDataFormatRelPath(virStorage= SourcePtr src, =20 return 0; } + +static bool +virStorageFileIsInitialized(const virStorageSource *src) +{ + return src && src->drv; +} + + +static virStorageFileBackendPtr +virStorageFileGetBackendForSupportCheck(const virStorageSource *src) +{ + int actualType; + + if (!src) + return NULL; + + if (src->drv) + return src->drv->backend; + + actualType =3D virStorageSourceGetActualType(src); + + return virStorageFileBackendForTypeInternal(actualType, src->protocol,= false); +} + + +static bool +virStorageFileSupportsBackingChainTraversal(virStorageSourcePtr src) +{ + virStorageFileBackendPtr backend; + + if (!(backend =3D virStorageFileGetBackendForSupportCheck(src))) + return false; + + return backend->storageFileGetUniqueIdentifier && + backend->storageFileRead && + backend->storageFileAccess; +} + + +/** + * virStorageFileSupportsSecurityDriver: + * + * @src: a storage file structure + * + * Check if a storage file supports operations needed by the security + * driver to perform labelling + */ +bool +virStorageFileSupportsSecurityDriver(const virStorageSource *src) +{ + virStorageFileBackendPtr backend; + + if (!(backend =3D virStorageFileGetBackendForSupportCheck(src))) + return false; + + return !!backend->storageFileChown; +} + + +/** + * virStorageFileSupportsAccess: + * + * @src: a storage file structure + * + * Check if a storage file supports checking if the storage source is acce= ssible + * for the given vm. + */ +bool +virStorageFileSupportsAccess(const virStorageSource *src) +{ + virStorageFileBackendPtr backend; + + if (!(backend =3D virStorageFileGetBackendForSupportCheck(src))) + return false; + + return !!backend->storageFileAccess; +} + + +void +virStorageFileDeinit(virStorageSourcePtr src) +{ + if (!virStorageFileIsInitialized(src)) + return; + + if (src->drv->backend && + src->drv->backend->backendDeinit) + src->drv->backend->backendDeinit(src); + + VIR_FREE(src->drv); +} + + +/** + * virStorageFileInitAs: + * + * @src: storage source definition + * @uid: uid used to access the file, or -1 for current uid + * @gid: gid used to access the file, or -1 for current gid + * + * Initialize a storage source to be used with storage driver. Use the pro= vided + * uid and gid if possible for the operations. + * + * Returns 0 if the storage file was successfully initialized, -1 if the + * initialization failed. Libvirt error is reported. + */ +int +virStorageFileInitAs(virStorageSourcePtr src, + uid_t uid, gid_t gid) +{ + int actualType =3D virStorageSourceGetActualType(src); + if (VIR_ALLOC(src->drv) < 0) + return -1; + + if (uid =3D=3D (uid_t) -1) + src->drv->uid =3D geteuid(); + else + src->drv->uid =3D uid; + + if (gid =3D=3D (gid_t) -1) + src->drv->gid =3D getegid(); + else + src->drv->gid =3D gid; + + if (!(src->drv->backend =3D virStorageFileBackendForType(actualType, + src->protocol))) + goto error; + + if (src->drv->backend->backendInit && + src->drv->backend->backendInit(src) < 0) + goto error; + + return 0; + + error: + VIR_FREE(src->drv); + return -1; +} + + +/** + * virStorageFileInit: + * + * See virStorageFileInitAs. The file is initialized to be accessed by the + * current user. + */ +int +virStorageFileInit(virStorageSourcePtr src) +{ + return virStorageFileInitAs(src, -1, -1); +} + + +/** + * virStorageFileCreate: Creates an empty storage file via storage driver + * + * @src: file structure pointing to the file + * + * Returns 0 on success, -2 if the function isn't supported by the backend, + * -1 on other failure. Errno is set in case of failure. + */ +int +virStorageFileCreate(virStorageSourcePtr src) +{ + int ret; + + if (!virStorageFileIsInitialized(src) || + !src->drv->backend->storageFileCreate) { + errno =3D ENOSYS; + return -2; + } + + ret =3D src->drv->backend->storageFileCreate(src); + + VIR_DEBUG("created storage file %p: ret=3D%d, errno=3D%d", + src, ret, errno); + + return ret; +} + + +/** + * virStorageFileUnlink: Unlink storage file via storage driver + * + * @src: file structure pointing to the file + * + * Unlinks the file described by the @file structure. + * + * Returns 0 on success, -2 if the function isn't supported by the backend, + * -1 on other failure. Errno is set in case of failure. + */ +int +virStorageFileUnlink(virStorageSourcePtr src) +{ + int ret; + + if (!virStorageFileIsInitialized(src) || + !src->drv->backend->storageFileUnlink) { + errno =3D ENOSYS; + return -2; + } + + ret =3D src->drv->backend->storageFileUnlink(src); + + VIR_DEBUG("unlinked storage file %p: ret=3D%d, errno=3D%d", + src, ret, errno); + + return ret; +} + + +/** + * virStorageFileStat: returns stat struct of a file via storage driver + * + * @src: file structure pointing to the file + * @stat: stat structure to return data + * + * Returns 0 on success, -2 if the function isn't supported by the backend, + * -1 on other failure. Errno is set in case of failure. +*/ +int +virStorageFileStat(virStorageSourcePtr src, + struct stat *st) +{ + int ret; + + if (!virStorageFileIsInitialized(src) || + !src->drv->backend->storageFileStat) { + errno =3D ENOSYS; + return -2; + } + + ret =3D src->drv->backend->storageFileStat(src, st); + + VIR_DEBUG("stat of storage file %p: ret=3D%d, errno=3D%d", + src, ret, errno); + + return ret; +} + + +/** + * virStorageFileRead: read bytes from a file into a buffer + * + * @src: file structure pointing to the file + * @offset: number of bytes to skip in the storage file + * @len: maximum number of bytes read from the storage file + * @buf: buffer to read the data into. (buffer shall be freed by caller) + * + * Returns the count of bytes read on success and -1 on failure, -2 if the + * function isn't supported by the backend. + * Libvirt error is reported on failure. + */ +ssize_t +virStorageFileRead(virStorageSourcePtr src, + size_t offset, + size_t len, + char **buf) +{ + ssize_t ret; + + if (!virStorageFileIsInitialized(src)) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("storage file backend not initialized")); + return -1; + } + + if (!src->drv->backend->storageFileRead) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("storage file reading is not supported for " + "storage type %s (protocol: %s)"), + virStorageTypeToString(src->type), + virStorageNetProtocolTypeToString(src->protocol)); + return -2; + } + + ret =3D src->drv->backend->storageFileRead(src, offset, len, buf); + + VIR_DEBUG("read '%zd' bytes from storage '%p' starting at offset '%zu'= ", + ret, src, offset); + + return ret; +} + + +/* + * virStorageFileGetUniqueIdentifier: Get a unique string describing the v= olume + * + * @src: file structure pointing to the file + * + * Returns a string uniquely describing a single volume (canonical path). + * The string shall not be freed and is valid until the storage file is + * deinitialized. Returns NULL on error and sets a libvirt error code */ +const char * +virStorageFileGetUniqueIdentifier(virStorageSourcePtr src) +{ + if (!virStorageFileIsInitialized(src)) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("storage file backend not initialized")); + return NULL; + } + + if (!src->drv->backend->storageFileGetUniqueIdentifier) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unique storage file identifier not implemented f= or " + "storage type %s (protocol: %s)'"), + virStorageTypeToString(src->type), + virStorageNetProtocolTypeToString(src->protocol)); + return NULL; + } + + return src->drv->backend->storageFileGetUniqueIdentifier(src); +} + + +/** + * virStorageFileAccess: Check accessibility of a storage file + * + * @src: storage file to check access permissions + * @mode: accessibility check options (see man 2 access) + * + * Returns 0 on success, -1 on error and sets errno. No libvirt + * error is reported. Returns -2 if the operation isn't supported + * by libvirt storage backend. + */ +int +virStorageFileAccess(virStorageSourcePtr src, + int mode) +{ + if (!virStorageFileIsInitialized(src) || + !src->drv->backend->storageFileAccess) { + errno =3D ENOSYS; + return -2; + } + + return src->drv->backend->storageFileAccess(src, mode); +} + + +/** + * virStorageFileChown: Change owner of a storage file + * + * @src: storage file to change owner of + * @uid: new owner id + * @gid: new group id + * + * Returns 0 on success, -1 on error and sets errno. No libvirt + * error is reported. Returns -2 if the operation isn't supported + * by libvirt storage backend. + */ +int +virStorageFileChown(const virStorageSource *src, + uid_t uid, + gid_t gid) +{ + if (!virStorageFileIsInitialized(src) || + !src->drv->backend->storageFileChown) { + errno =3D ENOSYS; + return -2; + } + + VIR_DEBUG("chown of storage file %p to %u:%u", + src, (unsigned int)uid, (unsigned int)gid); + + return src->drv->backend->storageFileChown(src, uid, gid); +} + + +/** + * virStorageFileReportBrokenChain: + * + * @errcode: errno when accessing @src + * @src: inaccessible file in the backing chain of @parent + * @parent: root virStorageSource being checked + * + * Reports the correct error message if @src is missing in the backing cha= in + * for @parent. + */ +void +virStorageFileReportBrokenChain(int errcode, + virStorageSourcePtr src, + virStorageSourcePtr parent) +{ + + if (src->drv) { + unsigned int access_user =3D src->drv->uid; + unsigned int access_group =3D src->drv->gid; + + if (src =3D=3D parent) { + virReportSystemError(errcode, + _("Cannot access storage file '%s' " + "(as uid:%u, gid:%u)"), + src->path, access_user, access_group); + } else { + virReportSystemError(errcode, + _("Cannot access backing file '%s' " + "of storage file '%s' (as uid:%u, gid:%= u)"), + src->path, parent->path, access_user, acc= ess_group); + } + } else { + if (src =3D=3D parent) { + virReportSystemError(errcode, + _("Cannot access storage file '%s'"), + src->path); + } else { + virReportSystemError(errcode, + _("Cannot access backing file '%s' " + "of storage file '%s'"), + src->path, parent->path); + } + } +} + + +/* Recursive workhorse for virStorageFileGetMetadata. */ +static int +virStorageFileGetMetadataRecurse(virStorageSourcePtr src, + virStorageSourcePtr parent, + uid_t uid, gid_t gid, + bool allow_probe, + bool report_broken, + virHashTablePtr cycle, + unsigned int depth) +{ + int ret =3D -1; + const char *uniqueName; + char *buf =3D NULL; + ssize_t headerLen; + virStorageSourcePtr backingStore =3D NULL; + int backingFormat; + + VIR_DEBUG("path=3D%s format=3D%d uid=3D%u gid=3D%u probe=3D%d", + src->path, src->format, + (unsigned int)uid, (unsigned int)gid, allow_probe); + + /* exit if we can't load information about the current image */ + if (!virStorageFileSupportsBackingChainTraversal(src)) + return 0; + + if (virStorageFileInitAs(src, uid, gid) < 0) + return -1; + + if (virStorageFileAccess(src, F_OK) < 0) { + virStorageFileReportBrokenChain(errno, src, parent); + goto cleanup; + } + + if (!(uniqueName =3D virStorageFileGetUniqueIdentifier(src))) + goto cleanup; + + if (virHashLookup(cycle, uniqueName)) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("backing store for %s (%s) is self-referential"), + src->path, uniqueName); + goto cleanup; + } + + if (virHashAddEntry(cycle, uniqueName, (void *)1) < 0) + goto cleanup; + + if ((headerLen =3D virStorageFileRead(src, 0, VIR_STORAGE_MAX_HEADER, + &buf)) < 0) + goto cleanup; + + if (virStorageFileGetMetadataInternal(src, buf, headerLen, + &backingFormat) < 0) + goto cleanup; + + if (src->backingStoreRaw) { + if (!(backingStore =3D virStorageSourceNewFromBacking(src))) + goto cleanup; + + if (backingFormat =3D=3D VIR_STORAGE_FILE_AUTO && !allow_probe) + backingStore->format =3D VIR_STORAGE_FILE_RAW; + else if (backingFormat =3D=3D VIR_STORAGE_FILE_AUTO_SAFE) + backingStore->format =3D VIR_STORAGE_FILE_AUTO; + else + backingStore->format =3D backingFormat; + + if ((ret =3D virStorageFileGetMetadataRecurse(backingStore, parent, + uid, gid, + allow_probe, report_br= oken, + cycle, depth + 1)) < 0= ) { + if (report_broken) + goto cleanup; + + /* if we fail somewhere midway, just accept and return a + * broken chain */ + ret =3D 0; + goto cleanup; + } + } else { + /* add terminator */ + if (VIR_ALLOC(backingStore) < 0) + goto cleanup; + } + + src->backingStore =3D backingStore; + backingStore =3D NULL; + ret =3D 0; + + cleanup: + if (virStorageSourceHasBacking(src)) + src->backingStore->id =3D depth; + VIR_FREE(buf); + virStorageFileDeinit(src); + virStorageSourceFree(backingStore); + return ret; +} + + +/** + * virStorageFileGetMetadata: + * + * Extract metadata about the storage volume with the specified + * image format. If image format is VIR_STORAGE_FILE_AUTO, it + * will probe to automatically identify the format. Recurses through + * the entire chain. + * + * Open files using UID and GID (or pass -1 for the current user/group). + * Treat any backing files without explicit type as raw, unless ALLOW_PROB= E. + * + * Callers are advised never to use VIR_STORAGE_FILE_AUTO as a + * format, since a malicious guest can turn a raw file into any + * other non-raw format at will. + * + * If @report_broken is true, the whole function fails with a possibly sane + * error instead of just returning a broken chain. + * + * Caller MUST free result after use via virStorageSourceFree. + */ +int +virStorageFileGetMetadata(virStorageSourcePtr src, + uid_t uid, gid_t gid, + bool allow_probe, + bool report_broken) +{ + VIR_DEBUG("path=3D%s format=3D%d uid=3D%u gid=3D%u probe=3D%d, report_= broken=3D%d", + src->path, src->format, (unsigned int)uid, (unsigned int)gid, + allow_probe, report_broken); + + virHashTablePtr cycle =3D NULL; + virStorageType actualType =3D virStorageSourceGetActualType(src); + int ret =3D -1; + + if (!(cycle =3D virHashCreate(5, NULL))) + return -1; + + if (src->format <=3D VIR_STORAGE_FILE_NONE) { + if (actualType =3D=3D VIR_STORAGE_TYPE_DIR) + src->format =3D VIR_STORAGE_FILE_DIR; + else if (allow_probe) + src->format =3D VIR_STORAGE_FILE_AUTO; + else + src->format =3D VIR_STORAGE_FILE_RAW; + } + + ret =3D virStorageFileGetMetadataRecurse(src, src, uid, gid, + allow_probe, report_broken, cyc= le, 1); + + virHashFree(cycle); + return ret; +} + + +/** + * virStorageFileGetBackingStoreStr: + * @src: storage object + * + * Extracts the backing store string as stored in the storage volume descr= ibed + * by @src and returns it to the user. Caller is responsible for freeing i= t. + * In case when the string can't be retrieved or does not exist NULL is + * returned. + */ +char * +virStorageFileGetBackingStoreStr(virStorageSourcePtr src) +{ + virStorageSourcePtr tmp =3D NULL; + char *buf =3D NULL; + ssize_t headerLen; + char *ret =3D NULL; + + /* exit if we can't load information about the current image */ + if (!virStorageFileSupportsBackingChainTraversal(src)) + return NULL; + + if (virStorageFileAccess(src, F_OK) < 0) + return NULL; + + if ((headerLen =3D virStorageFileRead(src, 0, VIR_STORAGE_MAX_HEADER, + &buf)) < 0) + return NULL; + + if (!(tmp =3D virStorageSourceCopy(src, false))) + goto cleanup; + + if (virStorageFileGetMetadataInternal(tmp, buf, headerLen, NULL) < 0) + goto cleanup; + + VIR_STEAL_PTR(ret, tmp->backingStoreRaw); + + cleanup: + VIR_FREE(buf); + virStorageSourceFree(tmp); + + return ret; +} diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index ecd806c93f..9e8afa4932 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -448,5 +448,37 @@ int virStorageSourcePrivateDataFormatRelPath(virStorageSourcePtr src, virBufferPtr buf); =20 +int virStorageFileInit(virStorageSourcePtr src); +int virStorageFileInitAs(virStorageSourcePtr src, + uid_t uid, gid_t gid); +void virStorageFileDeinit(virStorageSourcePtr src); + +int virStorageFileCreate(virStorageSourcePtr src); +int virStorageFileUnlink(virStorageSourcePtr src); +int virStorageFileStat(virStorageSourcePtr src, + struct stat *stat); +ssize_t virStorageFileRead(virStorageSourcePtr src, + size_t offset, + size_t len, + char **buf); +const char *virStorageFileGetUniqueIdentifier(virStorageSourcePtr src); +int virStorageFileAccess(virStorageSourcePtr src, int mode); +int virStorageFileChown(const virStorageSource *src, uid_t uid, gid_t gid); + +bool virStorageFileSupportsSecurityDriver(const virStorageSource *src); +bool virStorageFileSupportsAccess(const virStorageSource *src); + +int virStorageFileGetMetadata(virStorageSourcePtr src, + uid_t uid, gid_t gid, + bool allow_probe, + bool report_broken) + ATTRIBUTE_NONNULL(1); + +char *virStorageFileGetBackingStoreStr(virStorageSourcePtr src) + ATTRIBUTE_NONNULL(1); + +void virStorageFileReportBrokenChain(int errcode, + virStorageSourcePtr src, + virStorageSourcePtr parent); =20 #endif /* __VIR_STORAGE_FILE_H__ */ diff --git a/src/storage/storage_source_backend.c b/src/util/virstoragefile= backend.c similarity index 96% rename from src/storage/storage_source_backend.c rename to src/util/virstoragefilebackend.c index e093c04989..df86ee39c2 100644 --- a/src/storage/storage_source_backend.c +++ b/src/util/virstoragefilebackend.c @@ -1,5 +1,5 @@ /* - * storage_source_backend.c: internal storage source backend contract + * virstoragefilebackend.c: internal storage source backend contract * * Copyright (C) 2007-2018 Red Hat, Inc. * Copyright (C) 2007-2008 Daniel P. Berrange @@ -30,7 +30,7 @@ #include "virerror.h" #include "viralloc.h" #include "internal.h" -#include "storage_source_backend.h" +#include "virstoragefilebackend.h" #include "virlog.h" #include "virfile.h" #include "configmake.h" diff --git a/src/storage/storage_source_backend.h b/src/util/virstoragefile= backend.h similarity index 94% rename from src/storage/storage_source_backend.h rename to src/util/virstoragefilebackend.h index 8288bebb1f..6cd51750ee 100644 --- a/src/storage/storage_source_backend.h +++ b/src/util/virstoragefilebackend.h @@ -1,5 +1,5 @@ /* - * storage_source_backend.h: internal storage source backend contract + * virstoragefilebackend.h: internal storage source backend contract * * Copyright (C) 2007-2018 Red Hat, Inc. * @@ -18,8 +18,8 @@ * . */ =20 -#ifndef __VIR_STORAGE_SOURCE_BACKEND_H__ -# define __VIR_STORAGE_SOURCE_BACKEND_H__ +#ifndef __VIR_STORAGE_FILE_BACKEND_H__ +# define __VIR_STORAGE_FILE_BACKEND_H__ =20 # include =20 @@ -101,4 +101,4 @@ struct _virStorageFileBackend { =20 int virStorageFileBackendRegister(virStorageFileBackendPtr backend); =20 -#endif /* __VIR_STORAGE_BACKEND_H__ */ +#endif /* __VIR_STORAGE_FILE_BACKEND_H__ */ diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 7a0d4a8260..bc538e2e2a 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -32,7 +32,6 @@ #include "dirname.h" =20 #include "storage/storage_driver.h" -#include "storage/storage_source.h" =20 #define VIR_FROM_THIS VIR_FROM_NONE =20 --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 18:41:09 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 151687312508552.722442186627745; Thu, 25 Jan 2018 01:38:45 -0800 (PST) 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 19EA6780F0; Thu, 25 Jan 2018 09:38:44 +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 C1680600D1; Thu, 25 Jan 2018 09:38:43 +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 12B5C18033DB; Thu, 25 Jan 2018 09:38:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0P9ce7L003156 for ; Thu, 25 Jan 2018 04:38:40 -0500 Received: by smtp.corp.redhat.com (Postfix) id AFA996031B; Thu, 25 Jan 2018 09:38:40 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 77D7750F1F; Thu, 25 Jan 2018 09:38:39 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 25 Jan 2018 09:38:14 +0000 Message-Id: <20180125093825.5834-4-berrange@redhat.com> In-Reply-To: <20180125093825.5834-1-berrange@redhat.com> References: <20180125093825.5834-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 03/14] rpc: don't link in second copy of RPC code to libvirtd & lockd plugin 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.27]); Thu, 25 Jan 2018 09:38:44 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 The libvirt_driver_remote.la static library is linked into the libvirt.so dynamic library, providing both the generic RPC layer code and the remote protocol client driver. The libvirtd daemon the itself links to libvirt_driver_remote.la, in order to get access to the generic RPC layer code and the XDR functions for the remote driver. This means we get multiple copies of the same code in libvirtd, one direct and one indirect via libvirt.so. The same mistake affects the lockd plugin. The libvirtd daemon should instead just link aganist the generic RPC layer code that's in libvirt.so. This is easily doable if we add exports for the few symbols we've previously missed, and wildcard export xdr_* to expose the auto-generated XDR marshallers. Signed-off-by: Daniel P. Berrang=C3=A9 --- daemon/Makefile.am | 1 - src/Makefile.am | 12 +++++------- src/libvirt_remote.syms | 11 ++++++++++- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/daemon/Makefile.am b/daemon/Makefile.am index b0c28d2313..f7519efe2f 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -205,7 +205,6 @@ libvirtd_LDADD +=3D \ libvirtd_admin.la \ ../src/libvirt-lxc.la \ ../src/libvirt-qemu.la \ - ../src/libvirt_driver_remote.la \ $(NULL) =20 libvirtd_LDADD +=3D ../src/libvirt.la diff --git a/src/Makefile.am b/src/Makefile.am index 6b4db22937..ec2b4f631c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1310,16 +1310,11 @@ if WITH_REMOTE noinst_LTLIBRARIES +=3D libvirt_driver_remote.la libvirt_la_BUILT_LIBADD +=3D libvirt_driver_remote.la libvirt_driver_remote_la_CFLAGS =3D \ - $(GNUTLS_CFLAGS) \ $(XDR_CFLAGS) \ -I$(srcdir)/conf \ -I$(srcdir)/rpc \ $(AM_CFLAGS) libvirt_driver_remote_la_LDFLAGS =3D $(AM_LDFLAGS) -libvirt_driver_remote_la_LIBADD =3D $(GNUTLS_LIBS) \ - libvirt-net-rpc-client.la \ - libvirt-net-rpc-server.la \ - libvirt-net-rpc.la libvirt_driver_remote_la_SOURCES =3D $(REMOTE_DRIVER_SOURCES) =20 BUILT_SOURCES +=3D $(REMOTE_DRIVER_GENERATED) @@ -2574,8 +2569,6 @@ lockd_la_CFLAGS =3D -I$(srcdir)/conf \ $(AM_CFLAGS) lockd_la_LDFLAGS =3D -module -avoid-version $(AM_LDFLAGS) lockd_la_LIBADD =3D ../gnulib/lib/libgnu.la \ - libvirt-net-rpc.la \ - libvirt-net-rpc-client.la \ $(NULL) augeas_DATA +=3D locking/libvirt_lockd.aug if WITH_DTRACE_PROBES @@ -2889,6 +2882,11 @@ noinst_LTLIBRARIES +=3D \ libvirt-net-rpc-server.la \ libvirt-net-rpc-client.la =20 +libvirt_la_BUILT_LIBADD +=3D \ + libvirt-net-rpc.la \ + libvirt-net-rpc-server.la \ + libvirt-net-rpc-client.la + EXTRA_DIST +=3D \ dtrace2systemtap.pl \ rpc/gendispatch.pl \ diff --git a/src/libvirt_remote.syms b/src/libvirt_remote.syms index a181c4cf7f..da14a2449c 100644 --- a/src/libvirt_remote.syms +++ b/src/libvirt_remote.syms @@ -5,6 +5,9 @@ # Keep this file sorted by header name, then by symbols with each header. # =20 +# Generated files +xdr_*; + # rpc/virnetclient.h virNetClientAddProgram; virNetClientAddStream; @@ -80,6 +83,7 @@ virNetDaemonUpdateServices; =20 =20 # rpc/virnetmessage.h +virNetMessageAddFD; virNetMessageClear; virNetMessageClearPayload; virNetMessageDecodeHeader; @@ -96,7 +100,6 @@ virNetMessageNew; virNetMessageQueuePush; virNetMessageQueueServe; virNetMessageSaveError; -xdr_virNetMessageError; =20 =20 # rpc/virnetserver.h @@ -104,12 +107,14 @@ virNetServerAddClient; virNetServerAddProgram; virNetServerAddService; virNetServerClose; +virNetServerGetClient; virNetServerGetClients; virNetServerGetCurrentClients; virNetServerGetCurrentUnauthClients; virNetServerGetMaxClients; virNetServerGetMaxUnauthClients; virNetServerGetName; +virNetServerGetThreadPoolParameters; virNetServerHasClients; virNetServerNew; virNetServerNewPostExecRestart; @@ -117,6 +122,8 @@ virNetServerNextClientID; virNetServerPreExecRestart; virNetServerProcessClients; virNetServerSetClientAuthenticated; +virNetServerSetClientLimits; +virNetServerSetThreadPoolParameters; virNetServerStart; virNetServerUpdateServices; =20 @@ -128,11 +135,13 @@ virNetServerClientCloseLocked; virNetServerClientDelayedClose; virNetServerClientGetAuth; virNetServerClientGetFD; +virNetServerClientGetID; virNetServerClientGetIdentity; virNetServerClientGetInfo; virNetServerClientGetPrivateData; virNetServerClientGetReadonly; virNetServerClientGetSELinuxContext; +virNetServerClientGetTimestamp; virNetServerClientGetTransport; virNetServerClientGetUNIXIdentity; virNetServerClientImmediateClose; --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 18:41:09 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 151687312819155.279970317781476; Thu, 25 Jan 2018 01:38:48 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1641674867; Thu, 25 Jan 2018 09:38:47 +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 DEF442A2D4; Thu, 25 Jan 2018 09:38:46 +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 AB4035FBD8; Thu, 25 Jan 2018 09:38:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0P9cgqm003166 for ; Thu, 25 Jan 2018 04:38:42 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8AD726031B; Thu, 25 Jan 2018 09:38:42 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 50D8C6056B; Thu, 25 Jan 2018 09:38:41 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 25 Jan 2018 09:38:15 +0000 Message-Id: <20180125093825.5834-5-berrange@redhat.com> In-Reply-To: <20180125093825.5834-1-berrange@redhat.com> References: <20180125093825.5834-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 04/14] conf: introduce callback registration for domain net device allocation 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 25 Jan 2018 09:38:47 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Currently virt drivers will call directly into the network driver impl to allocate domain interface devices where type=3Dnetwork. This introduces a callback system to allow us to decouple the virt drivers from the network driver. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/conf/domain_conf.c | 54 +++++++++++++++++++++++++++++++++++++++++= ++++ src/conf/domain_conf.h | 34 ++++++++++++++++++++++++++++ src/libvirt_private.syms | 4 ++++ src/libxl/libxl_domain.c | 4 ++-- src/libxl/libxl_driver.c | 6 ++--- src/lxc/lxc_driver.c | 4 ++-- src/lxc/lxc_process.c | 6 ++--- src/network/bridge_driver.c | 32 ++++++++++++++++----------- src/network/bridge_driver.h | 28 ----------------------- src/qemu/qemu_hotplug.c | 14 ++++++------ src/qemu/qemu_process.c | 6 ++--- 11 files changed, 131 insertions(+), 61 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a1c25060f9..a3719164ae 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -28442,3 +28442,57 @@ virDomainNetTypeSharesHostView(const virDomainNetD= ef *net) } return false; } + +static virDomainNetAllocateActualDeviceImpl netAllocate; +static virDomainNetNotifyActualDeviceImpl netNotify; +static virDomainNetReleaseActualDeviceImpl netRelease; + +void +virDomainNetSetDeviceImpl(virDomainNetAllocateActualDeviceImpl allocate, + virDomainNetNotifyActualDeviceImpl notify, + virDomainNetReleaseActualDeviceImpl release) +{ + netAllocate =3D allocate; + netNotify =3D notify; + netRelease =3D release; +} + +int +virDomainNetAllocateActualDevice(virDomainDefPtr dom, + virDomainNetDefPtr iface) +{ + if (!netAllocate) { + virReportError(VIR_ERR_NO_SUPPORT, "%s", + _("Network device allocation not available")); + return -1; + } + + return netAllocate(dom, iface); +} + +void +virDomainNetNotifyActualDevice(virDomainDefPtr dom, + virDomainNetDefPtr iface) +{ + if (!netNotify) { + virReportError(VIR_ERR_NO_SUPPORT, "%s", + _("Network device notification not available")); + return; + } + + netNotify(dom, iface); +} + + +int +virDomainNetReleaseActualDevice(virDomainDefPtr dom, + virDomainNetDefPtr iface) +{ + if (!netRelease) { + virReportError(VIR_ERR_NO_SUPPORT, "%s", + _("Network device release not available")); + return -1; + } + + return netRelease(dom, iface); +} diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 6f7f96b3dd..1d1e3ac1a4 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3441,4 +3441,38 @@ bool virDomainDefLifecycleActionAllowed(virDomainLifecycle type, virDomainLifecycleAction action); =20 +typedef int +(*virDomainNetAllocateActualDeviceImpl)(virDomainDefPtr dom, + virDomainNetDefPtr iface); + +typedef void +(*virDomainNetNotifyActualDeviceImpl)(virDomainDefPtr dom, + virDomainNetDefPtr iface); + +typedef int +(*virDomainNetReleaseActualDeviceImpl)(virDomainDefPtr dom, + virDomainNetDefPtr iface); + +void +virDomainNetSetDeviceImpl(virDomainNetAllocateActualDeviceImpl allocate, + virDomainNetNotifyActualDeviceImpl notify, + virDomainNetReleaseActualDeviceImpl release); + +int +virDomainNetAllocateActualDevice(virDomainDefPtr dom, + virDomainNetDefPtr iface) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); + +void +virDomainNetNotifyActualDevice(virDomainDefPtr dom, + virDomainNetDefPtr iface) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); + +int +virDomainNetReleaseActualDevice(virDomainDefPtr dom, + virDomainNetDefPtr iface) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); + + + #endif /* __DOMAIN_CONF_H */ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 3d8ed0b9de..831b030b8c 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -430,6 +430,7 @@ virDomainMemoryInsert; virDomainMemoryRemove; virDomainMemorySourceTypeFromString; virDomainMemorySourceTypeToString; +virDomainNetAllocateActualDevice; virDomainNetAppendIPAddress; virDomainNetDefClear; virDomainNetDefFormat; @@ -449,8 +450,11 @@ virDomainNetGetActualType; virDomainNetGetActualVirtPortProfile; virDomainNetGetActualVlan; virDomainNetInsert; +virDomainNetNotifyActualDevice; +virDomainNetReleaseActualDevice; virDomainNetRemove; virDomainNetRemoveHostdev; +virDomainNetSetDeviceImpl; virDomainNetTypeFromString; virDomainNetTypeSharesHostView; virDomainNetTypeToString; diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 395c8a921b..8cc931a32f 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -796,7 +796,7 @@ libxlDomainCleanup(libxlDriverPrivatePtr driver, =20 /* cleanup actual device */ virDomainNetRemoveHostdev(vm->def, net); - networkReleaseActualDevice(vm->def, net); + virDomainNetReleaseActualDevice(vm->def, net); } } =20 @@ -955,7 +955,7 @@ libxlNetworkPrepareDevices(virDomainDefPtr def) * network's pool of devices, or resolve bridge device name * to the one defined in the network definition. */ - if (networkAllocateActualDevice(def, net) < 0) + if (virDomainNetAllocateActualDevice(def, net) < 0) return -1; =20 actualType =3D virDomainNetGetActualType(net); diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 79e29ce072..36aa840936 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -3349,7 +3349,7 @@ libxlDomainAttachNetDevice(libxlDriverPrivatePtr driv= er, * network's pool of devices, or resolve bridge device name * to the one defined in the network definition. */ - if (networkAllocateActualDevice(vm->def, net) < 0) + if (virDomainNetAllocateActualDevice(vm->def, net) < 0) goto cleanup; =20 actualType =3D virDomainNetGetActualType(net); @@ -3399,7 +3399,7 @@ libxlDomainAttachNetDevice(libxlDriverPrivatePtr driv= er, vm->def->nets[vm->def->nnets++] =3D net; } else { virDomainNetRemoveHostdev(vm->def, net); - networkReleaseActualDevice(vm->def, net); + virDomainNetReleaseActualDevice(vm->def, net); } virObjectUnref(cfg); return ret; @@ -3822,7 +3822,7 @@ libxlDomainDetachNetDevice(libxlDriverPrivatePtr driv= er, cleanup: libxl_device_nic_dispose(&nic); if (!ret) { - networkReleaseActualDevice(vm->def, detach); + virDomainNetReleaseActualDevice(vm->def, detach); virDomainNetRemove(vm->def, detachidx); } virObjectUnref(cfg); diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index b3447100fc..cc2f97205a 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -3944,7 +3944,7 @@ lxcDomainAttachDeviceNetLive(virConnectPtr conn, * network's pool of devices, or resolve bridge device name * to the one defined in the network definition. */ - if (networkAllocateActualDevice(vm->def, net) < 0) + if (virDomainNetAllocateActualDevice(vm->def, net) < 0) return -1; =20 actualType =3D virDomainNetGetActualType(net); @@ -4468,7 +4468,7 @@ lxcDomainDetachDeviceNetLive(virDomainObjPtr vm, ret =3D 0; cleanup: if (!ret) { - networkReleaseActualDevice(vm->def, detach); + virDomainNetReleaseActualDevice(vm->def, detach); virDomainNetRemove(vm->def, detachidx); virDomainNetDefFree(detach); } diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index efd8a69000..06bedfe73b 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -219,7 +219,7 @@ static void virLXCProcessCleanup(virLXCDriverPtr driver, iface->ifname)); ignore_value(virNetDevVethDelete(iface->ifname)); } - networkReleaseActualDevice(vm->def, iface); + virDomainNetReleaseActualDevice(vm->def, iface); } =20 virDomainConfVMNWFilterTeardown(vm); @@ -553,7 +553,7 @@ static int virLXCProcessSetupInterfaces(virConnectPtr c= onn, if (virLXCProcessValidateInterface(net) < 0) return -1; =20 - if (networkAllocateActualDevice(def, net) < 0) + if (virDomainNetAllocateActualDevice(def, net) < 0) goto cleanup; =20 if (VIR_EXPAND_N(*veths, *nveths, 1) < 0) @@ -635,7 +635,7 @@ static int virLXCProcessSetupInterfaces(virConnectPtr c= onn, ignore_value(virNetDevOpenvswitchRemovePort( virDomainNetGetActualBridgeName(iface), iface->ifname)); - networkReleaseActualDevice(def, iface); + virDomainNetReleaseActualDevice(def, iface); } } return ret; diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 334da7a85d..a492b190e4 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -4275,16 +4275,6 @@ static virStateDriver networkStateDriver =3D { .stateReload =3D networkStateReload, }; =20 -int -networkRegister(void) -{ - if (virSetSharedNetworkDriver(&networkDriver) < 0) - return -1; - if (virRegisterStateDriver(&networkStateDriver) < 0) - return -1; - return 0; -} - =20 /* A unified function to log network connections and disconnections */ =20 @@ -4342,7 +4332,7 @@ networkLogAllocation(virNetworkDefPtr netdef, * * Returns 0 on success, -1 on failure. */ -int +static int networkAllocateActualDevice(virDomainDefPtr dom, virDomainNetDefPtr iface) { @@ -4764,7 +4754,7 @@ networkAllocateActualDevice(virDomainDefPtr dom, * * No return value (but does log any failures) */ -void +static void networkNotifyActualDevice(virDomainDefPtr dom, virDomainNetDefPtr iface) { @@ -4981,7 +4971,7 @@ networkNotifyActualDevice(virDomainDefPtr dom, * * Returns 0 on success, -1 on failure. */ -int +static int networkReleaseActualDevice(virDomainDefPtr dom, virDomainNetDefPtr iface) { @@ -5716,3 +5706,19 @@ networkBandwidthUpdate(virDomainNetDefPtr iface, virNetworkObjEndAPI(&obj); return ret; } + +int +networkRegister(void) +{ + if (virSetSharedNetworkDriver(&networkDriver) < 0) + return -1; + if (virRegisterStateDriver(&networkStateDriver) < 0) + return -1; + + virDomainNetSetDeviceImpl( + networkAllocateActualDevice, + networkNotifyActualDevice, + networkReleaseActualDevice); + + return 0; +} diff --git a/src/network/bridge_driver.h b/src/network/bridge_driver.h index 6d9aece656..dbb4fa8086 100644 --- a/src/network/bridge_driver.h +++ b/src/network/bridge_driver.h @@ -35,20 +35,6 @@ int networkRegister(void); =20 # if WITH_NETWORK -int -networkAllocateActualDevice(virDomainDefPtr dom, - virDomainNetDefPtr iface) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); - -void -networkNotifyActualDevice(virDomainDefPtr dom, - virDomainNetDefPtr iface) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); - -int -networkReleaseActualDevice(virDomainDefPtr dom, - virDomainNetDefPtr iface) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); =20 int networkGetNetworkAddress(const char *netname, @@ -78,25 +64,11 @@ networkBandwidthUpdate(virDomainNetDefPtr iface, =20 # else /* Define no-op replacements that don't drag in any link dependencies. */ -# define networkAllocateActualDevice(dom, iface) 0 # define networkGetActualType(iface) (iface->type) # define networkGetNetworkAddress(netname, netaddr) (-2) # define networkDnsmasqConfContents(network, pidfile, configstr, \ dctx, caps) 0 =20 -static inline void -networkNotifyActualDevice(virDomainDefPtr dom ATTRIBUTE_UNUSED, - virDomainNetDefPtr iface ATTRIBUTE_UNUSED) -{ -} - -static inline int -networkReleaseActualDevice(virDomainDefPtr dom ATTRIBUTE_UNUSED, - virDomainNetDefPtr iface ATTRIBUTE_UNUSED) -{ - return 0; -} - static inline bool networkBandwidthChangeAllowed(virDomainNetDefPtr iface ATTRIBUTE_UNUSED, virNetDevBandwidthPtr newBandwidth ATTRIBUTE= _UNUSED) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 6b245bd6ac..2ab60919bb 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -851,7 +851,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, * network's pool of devices, or resolve bridge device name * to the one defined in the network definition. */ - if (networkAllocateActualDevice(vm->def, net) < 0) + if (virDomainNetAllocateActualDevice(vm->def, net) < 0) goto cleanup; =20 actualType =3D virDomainNetGetActualType(net); @@ -1182,7 +1182,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, =20 virDomainNetRemoveHostdev(vm->def, net); =20 - networkReleaseActualDevice(vm->def, net); + virDomainNetReleaseActualDevice(vm->def, net); } =20 VIR_FREE(nicstr); @@ -3229,7 +3229,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, * free it if we fail for any reason */ if (newdev->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK && - networkAllocateActualDevice(vm->def, newdev) < 0) { + virDomainNetAllocateActualDevice(vm->def, newdev) < 0) { goto cleanup; } =20 @@ -3437,7 +3437,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, =20 /* this function doesn't work with HOSTDEV networks yet, thus * no need to change the pointer in the hostdev structure */ - networkReleaseActualDevice(vm->def, olddev); + virDomainNetReleaseActualDevice(vm->def, olddev); virDomainNetDefFree(olddev); /* move newdev into the nets list, and NULL it out from the * virDomainDeviceDef that we were given so that the caller @@ -3469,7 +3469,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, * replace the entire device object. */ if (newdev) - networkReleaseActualDevice(vm->def, newdev); + virDomainNetReleaseActualDevice(vm->def, newdev); =20 return ret; } @@ -4051,7 +4051,7 @@ qemuDomainRemoveHostDevice(virQEMUDriverPtr driver, virDomainHostdevDefFree(hostdev); =20 if (net) { - networkReleaseActualDevice(vm->def, net); + virDomainNetReleaseActualDevice(vm->def, net); virDomainNetDefFree(net); } =20 @@ -4162,7 +4162,7 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver, =20 qemuDomainNetDeviceVportRemove(net); =20 - networkReleaseActualDevice(vm->def, net); + virDomainNetReleaseActualDevice(vm->def, net); virDomainNetDefFree(net); ret =3D 0; =20 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 25ec464d3e..29af643160 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -2895,7 +2895,7 @@ qemuProcessNotifyNets(virDomainDefPtr def) if (virDomainNetGetActualType(net) =3D=3D VIR_DOMAIN_NET_TYPE_DIRE= CT) ignore_value(virNetDevMacVLanReserveName(net->ifname, false)); =20 - networkNotifyActualDevice(def, net); + virDomainNetNotifyActualDevice(def, net); } } =20 @@ -4965,7 +4965,7 @@ qemuProcessNetworkPrepareDevices(virDomainDefPtr def) * network's pool of devices, or resolve bridge device name * to the one defined in the network definition. */ - if (networkAllocateActualDevice(def, net) < 0) + if (virDomainNetAllocateActualDevice(def, net) < 0) goto cleanup; =20 actualType =3D virDomainNetGetActualType(net); @@ -6531,7 +6531,7 @@ void qemuProcessStop(virQEMUDriverPtr driver, =20 /* kick the device out of the hostdev list too */ virDomainNetRemoveHostdev(def, net); - networkReleaseActualDevice(vm->def, net); + virDomainNetReleaseActualDevice(vm->def, net); } =20 retry: --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 18:41:09 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1516873127936261.8731193110533; Thu, 25 Jan 2018 01:38:47 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AA874D7136; Thu, 25 Jan 2018 09:38:46 +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 8354360C9D; Thu, 25 Jan 2018 09:38:46 +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 35ADB18033DD; Thu, 25 Jan 2018 09:38:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0P9ciUr003178 for ; Thu, 25 Jan 2018 04:38:44 -0500 Received: by smtp.corp.redhat.com (Postfix) id B2DC2600D1; Thu, 25 Jan 2018 09:38:44 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 42E9D50F4E; Thu, 25 Jan 2018 09:38:42 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 25 Jan 2018 09:38:16 +0000 Message-Id: <20180125093825.5834-6-berrange@redhat.com> In-Reply-To: <20180125093825.5834-1-berrange@redhat.com> References: <20180125093825.5834-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 05/14] conf: expand network device callbacks to cover bandwidth updates 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 25 Jan 2018 09:38:47 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Currently the QEMU driver will call directly into the network driver impl to modify network device bandwidth for interfaces with type=3Dnetwork. This introduces a callback system to allow us to decouple the QEMU driver from the network driver. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/conf/domain_conf.c | 35 ++++++++++++++++++++++++++++++++++- src/conf/domain_conf.h | 22 +++++++++++++++++++++- src/libvirt_private.syms | 2 ++ src/network/bridge_driver.c | 8 +++++--- src/network/bridge_driver.h | 24 ------------------------ src/qemu/qemu_driver.c | 4 ++-- 6 files changed, 64 insertions(+), 31 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a3719164ae..5cae6f51cf 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -28446,15 +28446,22 @@ virDomainNetTypeSharesHostView(const virDomainNet= Def *net) static virDomainNetAllocateActualDeviceImpl netAllocate; static virDomainNetNotifyActualDeviceImpl netNotify; static virDomainNetReleaseActualDeviceImpl netRelease; +static virDomainNetBandwidthChangeAllowedImpl netBandwidthChangeAllowed; +static virDomainNetBandwidthUpdateImpl netBandwidthUpdate; + =20 void virDomainNetSetDeviceImpl(virDomainNetAllocateActualDeviceImpl allocate, virDomainNetNotifyActualDeviceImpl notify, - virDomainNetReleaseActualDeviceImpl release) + virDomainNetReleaseActualDeviceImpl release, + virDomainNetBandwidthChangeAllowedImpl bandwidth= ChangeAllowed, + virDomainNetBandwidthUpdateImpl bandwidthUpdate) { netAllocate =3D allocate; netNotify =3D notify; netRelease =3D release; + netBandwidthChangeAllowed =3D bandwidthChangeAllowed; + netBandwidthUpdate =3D bandwidthUpdate; } =20 int @@ -28496,3 +28503,29 @@ virDomainNetReleaseActualDevice(virDomainDefPtr do= m, =20 return netRelease(dom, iface); } + +bool +virDomainNetBandwidthChangeAllowed(virDomainNetDefPtr iface, + virNetDevBandwidthPtr newBandwidth) +{ + if (!netBandwidthChangeAllowed) { + virReportError(VIR_ERR_NO_SUPPORT, "%s", + _("Network device release not available")); + return -1; + } + + return netBandwidthChangeAllowed(iface, newBandwidth); +} + +int +virDomainNetBandwidthUpdate(virDomainNetDefPtr iface, + virNetDevBandwidthPtr newBandwidth) +{ + if (!netBandwidthUpdate) { + virReportError(VIR_ERR_NO_SUPPORT, "%s", + _("Network device release not available")); + return -1; + } + + return netBandwidthUpdate(iface, newBandwidth); +} diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 1d1e3ac1a4..e876fe953d 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3453,10 +3453,21 @@ typedef int (*virDomainNetReleaseActualDeviceImpl)(virDomainDefPtr dom, virDomainNetDefPtr iface); =20 +typedef bool +(*virDomainNetBandwidthChangeAllowedImpl)(virDomainNetDefPtr iface, + virNetDevBandwidthPtr newBandwid= th); + +typedef int +(*virDomainNetBandwidthUpdateImpl)(virDomainNetDefPtr iface, + virNetDevBandwidthPtr newBandwidth); + + void virDomainNetSetDeviceImpl(virDomainNetAllocateActualDeviceImpl allocate, virDomainNetNotifyActualDeviceImpl notify, - virDomainNetReleaseActualDeviceImpl release); + virDomainNetReleaseActualDeviceImpl release, + virDomainNetBandwidthChangeAllowedImpl bandwidth= ChangeAllowed, + virDomainNetBandwidthUpdateImpl bandwidthUpdate); =20 int virDomainNetAllocateActualDevice(virDomainDefPtr dom, @@ -3473,6 +3484,15 @@ virDomainNetReleaseActualDevice(virDomainDefPtr dom, virDomainNetDefPtr iface) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); =20 +bool +virDomainNetBandwidthChangeAllowed(virDomainNetDefPtr iface, + virNetDevBandwidthPtr newBandwidth) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); + +int +virDomainNetBandwidthUpdate(virDomainNetDefPtr iface, + virNetDevBandwidthPtr newBandwidth) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); =20 =20 #endif /* __DOMAIN_CONF_H */ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 831b030b8c..10d8e65b62 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -432,6 +432,8 @@ virDomainMemorySourceTypeFromString; virDomainMemorySourceTypeToString; virDomainNetAllocateActualDevice; virDomainNetAppendIPAddress; +virDomainNetBandwidthChangeAllowed; +virDomainNetBandwidthUpdate; virDomainNetDefClear; virDomainNetDefFormat; virDomainNetDefFree; diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index a492b190e4..a0e45d1f65 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -5589,7 +5589,7 @@ networkBandwidthGenericChecks(virDomainNetDefPtr ifac= e, } =20 =20 -bool +static bool networkBandwidthChangeAllowed(virDomainNetDefPtr iface, virNetDevBandwidthPtr newBandwidth) { @@ -5620,7 +5620,7 @@ networkBandwidthChangeAllowed(virDomainNetDefPtr ifac= e, } =20 =20 -int +static int networkBandwidthUpdate(virDomainNetDefPtr iface, virNetDevBandwidthPtr newBandwidth) { @@ -5718,7 +5718,9 @@ networkRegister(void) virDomainNetSetDeviceImpl( networkAllocateActualDevice, networkNotifyActualDevice, - networkReleaseActualDevice); + networkReleaseActualDevice, + networkBandwidthChangeAllowed, + networkBandwidthUpdate); =20 return 0; } diff --git a/src/network/bridge_driver.h b/src/network/bridge_driver.h index dbb4fa8086..098f9e5c5b 100644 --- a/src/network/bridge_driver.h +++ b/src/network/bridge_driver.h @@ -52,16 +52,6 @@ networkDnsmasqConfContents(virNetworkObjPtr obj, dnsmasqContext *dctx, dnsmasqCapsPtr caps); =20 -bool -networkBandwidthChangeAllowed(virDomainNetDefPtr iface, - virNetDevBandwidthPtr newBandwidth) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); - -int -networkBandwidthUpdate(virDomainNetDefPtr iface, - virNetDevBandwidthPtr newBandwidth) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); - # else /* Define no-op replacements that don't drag in any link dependencies. */ # define networkGetActualType(iface) (iface->type) @@ -69,20 +59,6 @@ networkBandwidthUpdate(virDomainNetDefPtr iface, # define networkDnsmasqConfContents(network, pidfile, configstr, \ dctx, caps) 0 =20 -static inline bool -networkBandwidthChangeAllowed(virDomainNetDefPtr iface ATTRIBUTE_UNUSED, - virNetDevBandwidthPtr newBandwidth ATTRIBUTE= _UNUSED) -{ - return true; -} - -static inline int -networkBandwidthUpdate(virDomainNetDefPtr iface ATTRIBUTE_UNUSED, - virNetDevBandwidthPtr newBandwidth ATTRIBUTE_UNUSED) -{ - return 0; -} - # endif =20 #endif /* __VIR_NETWORK__DRIVER_H */ diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 28ca4c09cc..a2a4c984df 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -11264,12 +11264,12 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, sizeof(*newBandwidth->out)); } =20 - if (!networkBandwidthChangeAllowed(net, newBandwidth)) + if (!virDomainNetBandwidthChangeAllowed(net, newBandwidth)) goto endjob; =20 if (virNetDevBandwidthSet(net->ifname, newBandwidth, false, !virDomainNetTypeSharesHostView(net)) < = 0 || - networkBandwidthUpdate(net, newBandwidth) < 0) { + virDomainNetBandwidthUpdate(net, newBandwidth) < 0) { ignore_value(virNetDevBandwidthSet(net->ifname, net->bandwidth, false, --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 18:41:09 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1516873131101445.7904632820463; Thu, 25 Jan 2018 01:38:51 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0A7C96516B; Thu, 25 Jan 2018 09:38:50 +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 D20711801A; Thu, 25 Jan 2018 09:38:49 +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 978115FBE3; Thu, 25 Jan 2018 09:38:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0P9ckWV003189 for ; Thu, 25 Jan 2018 04:38:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id CC73950F4E; Thu, 25 Jan 2018 09:38:46 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4FD136031B; Thu, 25 Jan 2018 09:38:45 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 25 Jan 2018 09:38:17 +0000 Message-Id: <20180125093825.5834-7-berrange@redhat.com> In-Reply-To: <20180125093825.5834-1-berrange@redhat.com> References: <20180125093825.5834-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 06/14] qemu: replace networkGetNetworkAddress with public API calls 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 25 Jan 2018 09:38:50 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 The QEMU driver calls into the network driver to get the first IP address of the network. This information is readily available via the formal public API by fetching the XML doc and then parsing it. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/network/bridge_driver.c | 98 ----------------------------------------- src/network/bridge_driver.h | 6 --- src/qemu/qemu_process.c | 103 ++++++++++++++++++++++++++++++++++++++++= +--- 3 files changed, 96 insertions(+), 111 deletions(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index a0e45d1f65..ee200f1343 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -5104,104 +5104,6 @@ networkReleaseActualDevice(virDomainDefPtr dom, } =20 =20 -/* - * networkGetNetworkAddress: - * @netname: the name of a network - * @netaddr: string representation of IP address for that network. - * - * Attempt to return an IP address associated with the named - * network. If a libvirt virtual network, that will be provided in the - * configuration. For host bridge and direct (macvtap) networks, we - * must do an ioctl to learn the address. - * - * Note: This function returns the first IP address it finds. It might - * be useful if it was more flexible, but the current use (getting a - * listen address for qemu's vnc/spice graphics server) can only use a - * single address anyway. - * - * Returns 0 on success, and puts a string (which must be free'd by - * the caller) into *netaddr. Returns -1 on failure or -2 if - * completely unsupported. - */ -int -networkGetNetworkAddress(const char *netname, - char **netaddr) -{ - virNetworkDriverStatePtr driver =3D networkGetDriver(); - int ret =3D -1; - virNetworkObjPtr obj; - virNetworkDefPtr netdef; - virNetworkIPDefPtr ipdef; - virSocketAddr addr; - virSocketAddrPtr addrptr =3D NULL; - char *dev_name =3D NULL; - - *netaddr =3D NULL; - obj =3D virNetworkObjFindByName(driver->networks, netname); - if (!obj) { - virReportError(VIR_ERR_NO_NETWORK, - _("no network with matching name '%s'"), - netname); - goto cleanup; - } - netdef =3D virNetworkObjGetDef(obj); - - switch (netdef->forward.type) { - case VIR_NETWORK_FORWARD_NONE: - case VIR_NETWORK_FORWARD_NAT: - case VIR_NETWORK_FORWARD_ROUTE: - case VIR_NETWORK_FORWARD_OPEN: - ipdef =3D virNetworkDefGetIPByIndex(netdef, AF_UNSPEC, 0); - if (!ipdef) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("network '%s' doesn't have an IP address"), - netdef->name); - goto cleanup; - } - addrptr =3D &ipdef->address; - break; - - case VIR_NETWORK_FORWARD_BRIDGE: - if ((dev_name =3D netdef->bridge)) - break; - /* - * fall through if netdef->bridge wasn't set, since that is - * macvtap bridge mode network. - */ - ATTRIBUTE_FALLTHROUGH; - - case VIR_NETWORK_FORWARD_PRIVATE: - case VIR_NETWORK_FORWARD_VEPA: - case VIR_NETWORK_FORWARD_PASSTHROUGH: - if ((netdef->forward.nifs > 0) && netdef->forward.ifs) - dev_name =3D netdef->forward.ifs[0].device.dev; - - if (!dev_name) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("network '%s' has no associated interface or = bridge"), - netdef->name); - goto cleanup; - } - break; - } - - if (dev_name) { - if (virNetDevIPAddrGet(dev_name, &addr) < 0) - goto cleanup; - addrptr =3D &addr; - } - - if (!(addrptr && - (*netaddr =3D virSocketAddrFormat(addrptr)))) { - goto cleanup; - } - - ret =3D 0; - cleanup: - virNetworkObjEndAPI(&obj); - return ret; -} - =20 /* networkGetActualType: * @dom: domain definition that @iface belongs to diff --git a/src/network/bridge_driver.h b/src/network/bridge_driver.h index 098f9e5c5b..6fa6432d13 100644 --- a/src/network/bridge_driver.h +++ b/src/network/bridge_driver.h @@ -36,11 +36,6 @@ networkRegister(void); =20 # if WITH_NETWORK =20 -int -networkGetNetworkAddress(const char *netname, - char **netaddr) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); - int networkGetActualType(virDomainNetDefPtr iface) ATTRIBUTE_NONNULL(1); @@ -55,7 +50,6 @@ networkDnsmasqConfContents(virNetworkObjPtr obj, # else /* Define no-op replacements that don't drag in any link dependencies. */ # define networkGetActualType(iface) (iface->type) -# define networkGetNetworkAddress(netname, netaddr) (-2) # define networkDnsmasqConfContents(network, pidfile, configstr, \ dctx, caps) 0 =20 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 29af643160..2c352523fe 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4259,9 +4259,95 @@ qemuProcessGraphicsAllocatePorts(virQEMUDriverPtr dr= iver, return 0; } =20 +static int +qemuProcessGetNetworkAddress(virConnectPtr conn, + const char *netname, + char **netaddr) +{ + int ret =3D -1; + virNetworkPtr net; + virNetworkDefPtr netdef =3D NULL; + virNetworkIPDefPtr ipdef; + virSocketAddr addr; + virSocketAddrPtr addrptr =3D NULL; + char *dev_name =3D NULL; + char *xml =3D NULL; + + *netaddr =3D NULL; + net =3D virNetworkLookupByName(conn, netname); + if (!net) + goto cleanup; + + xml =3D virNetworkGetXMLDesc(net, 0); + if (!xml) + goto cleanup; + + netdef =3D virNetworkDefParseString(xml); + if (!netdef) + goto cleanup; + + switch (netdef->forward.type) { + case VIR_NETWORK_FORWARD_NONE: + case VIR_NETWORK_FORWARD_NAT: + case VIR_NETWORK_FORWARD_ROUTE: + case VIR_NETWORK_FORWARD_OPEN: + ipdef =3D virNetworkDefGetIPByIndex(netdef, AF_UNSPEC, 0); + if (!ipdef) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("network '%s' doesn't have an IP address"), + netdef->name); + goto cleanup; + } + addrptr =3D &ipdef->address; + break; + + case VIR_NETWORK_FORWARD_BRIDGE: + if ((dev_name =3D netdef->bridge)) + break; + /* + * fall through if netdef->bridge wasn't set, since that is + * macvtap bridge mode network. + */ + ATTRIBUTE_FALLTHROUGH; + + case VIR_NETWORK_FORWARD_PRIVATE: + case VIR_NETWORK_FORWARD_VEPA: + case VIR_NETWORK_FORWARD_PASSTHROUGH: + if ((netdef->forward.nifs > 0) && netdef->forward.ifs) + dev_name =3D netdef->forward.ifs[0].device.dev; + + if (!dev_name) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("network '%s' has no associated interface or = bridge"), + netdef->name); + goto cleanup; + } + break; + } + + if (dev_name) { + if (virNetDevIPAddrGet(dev_name, &addr) < 0) + goto cleanup; + addrptr =3D &addr; + } + + if (!(addrptr && + (*netaddr =3D virSocketAddrFormat(addrptr)))) { + goto cleanup; + } + + ret =3D 0; + cleanup: + virNetworkDefFree(netdef); + virObjectUnref(net); + VIR_FREE(xml); + return ret; +} + =20 static int -qemuProcessGraphicsSetupNetworkAddress(virDomainGraphicsListenDefPtr glist= en, +qemuProcessGraphicsSetupNetworkAddress(virConnectPtr conn, + virDomainGraphicsListenDefPtr glist= en, const char *listenAddr) { int rc; @@ -4273,7 +4359,7 @@ qemuProcessGraphicsSetupNetworkAddress(virDomainGraph= icsListenDefPtr glisten, return 0; } =20 - rc =3D networkGetNetworkAddress(glisten->network, &glisten->address); + rc =3D qemuProcessGetNetworkAddress(conn, glisten->network, &glisten->= address); if (rc <=3D -2) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("network-based listen isn't possible, " @@ -4288,7 +4374,8 @@ qemuProcessGraphicsSetupNetworkAddress(virDomainGraph= icsListenDefPtr glisten, =20 =20 static int -qemuProcessGraphicsSetupListen(virQEMUDriverPtr driver, +qemuProcessGraphicsSetupListen(virConnectPtr conn, + virQEMUDriverPtr driver, virDomainGraphicsDefPtr graphics, virDomainObjPtr vm) { @@ -4346,7 +4433,8 @@ qemuProcessGraphicsSetupListen(virQEMUDriverPtr drive= r, if (glisten->address || !listenAddr) continue; =20 - if (qemuProcessGraphicsSetupNetworkAddress(glisten, + if (qemuProcessGraphicsSetupNetworkAddress(conn, + glisten, listenAddr) < 0) goto cleanup; break; @@ -4375,7 +4463,8 @@ qemuProcessGraphicsSetupListen(virQEMUDriverPtr drive= r, =20 =20 static int -qemuProcessSetupGraphics(virQEMUDriverPtr driver, +qemuProcessSetupGraphics(virConnectPtr conn, + virQEMUDriverPtr driver, virDomainObjPtr vm, unsigned int flags) { @@ -4387,7 +4476,7 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver, for (i =3D 0; i < vm->def->ngraphics; i++) { graphics =3D vm->def->graphics[i]; =20 - if (qemuProcessGraphicsSetupListen(driver, graphics, vm) < 0) + if (qemuProcessGraphicsSetupListen(conn, driver, graphics, vm) < 0) goto cleanup; } =20 @@ -5529,7 +5618,7 @@ qemuProcessPrepareDomain(virConnectPtr conn, goto cleanup; =20 VIR_DEBUG("Setting graphics devices"); - if (qemuProcessSetupGraphics(driver, vm, flags) < 0) + if (qemuProcessSetupGraphics(conn, driver, vm, flags) < 0) goto cleanup; =20 VIR_DEBUG("Create domain masterKey"); --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 18:41:09 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1516873136394283.77467648061236; Thu, 25 Jan 2018 01:38:56 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 70618D7807; Thu, 25 Jan 2018 09:38:55 +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 440B460E39; Thu, 25 Jan 2018 09:38:55 +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 EF5E418033E4; Thu, 25 Jan 2018 09:38:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0P9crAe003205 for ; Thu, 25 Jan 2018 04:38:53 -0500 Received: by smtp.corp.redhat.com (Postfix) id 99A396056B; Thu, 25 Jan 2018 09:38:53 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B75F6031B; Thu, 25 Jan 2018 09:38:47 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 25 Jan 2018 09:38:18 +0000 Message-Id: <20180125093825.5834-8-berrange@redhat.com> In-Reply-To: <20180125093825.5834-1-berrange@redhat.com> References: <20180125093825.5834-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 07/14] conf: expand network device callbacks to cover resolving NIC type 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 25 Jan 2018 09:38:55 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Currently the QEMU driver will call directly into the network driver impl to modify resolve the atual type of NICs with type=3Dnetwork. It has todo this before it has allocated the actual NIC. This introduces a callback system to allow us to decouple the QEMU driver from the network driver. This is a short term step, as it ought to be possible to achieve the same end goal by simply querying XML via the public network API. The QEMU code in question though, has no virConnectPtr conveniently available at this time. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/conf/domain_conf.c | 17 ++++++++++++++++- src/conf/domain_conf.h | 15 ++++++++++++++- src/libvirt_private.syms | 1 + src/network/bridge_driver.c | 10 +++++----- src/network/bridge_driver.h | 5 ----- src/qemu/qemu_alias.c | 2 +- src/qemu/qemu_domain_address.c | 2 +- 7 files changed, 38 insertions(+), 14 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5cae6f51cf..05892c30d9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -28448,6 +28448,7 @@ static virDomainNetNotifyActualDeviceImpl netNotify; static virDomainNetReleaseActualDeviceImpl netRelease; static virDomainNetBandwidthChangeAllowedImpl netBandwidthChangeAllowed; static virDomainNetBandwidthUpdateImpl netBandwidthUpdate; +static virDomainNetResolveActualTypeImpl netResolveActualType; =20 =20 void @@ -28455,13 +28456,15 @@ virDomainNetSetDeviceImpl(virDomainNetAllocateAct= ualDeviceImpl allocate, virDomainNetNotifyActualDeviceImpl notify, virDomainNetReleaseActualDeviceImpl release, virDomainNetBandwidthChangeAllowedImpl bandwidth= ChangeAllowed, - virDomainNetBandwidthUpdateImpl bandwidthUpdate) + virDomainNetBandwidthUpdateImpl bandwidthUpdate, + virDomainNetResolveActualTypeImpl resolveActualT= ype) { netAllocate =3D allocate; netNotify =3D notify; netRelease =3D release; netBandwidthChangeAllowed =3D bandwidthChangeAllowed; netBandwidthUpdate =3D bandwidthUpdate; + netResolveActualType =3D resolveActualType; } =20 int @@ -28529,3 +28532,15 @@ virDomainNetBandwidthUpdate(virDomainNetDefPtr ifa= ce, =20 return netBandwidthUpdate(iface, newBandwidth); } + +int +virDomainNetResolveActualType(virDomainNetDefPtr iface) +{ + if (!netResolveActualType) { + virReportError(VIR_ERR_NO_SUPPORT, "%s", + _("Network device resolve type not available")); + return -1; + } + + return netResolveActualType(iface); +} diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index e876fe953d..d1f4038295 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3461,13 +3461,17 @@ typedef int (*virDomainNetBandwidthUpdateImpl)(virDomainNetDefPtr iface, virNetDevBandwidthPtr newBandwidth); =20 +typedef int +(*virDomainNetResolveActualTypeImpl)(virDomainNetDefPtr iface); + =20 void virDomainNetSetDeviceImpl(virDomainNetAllocateActualDeviceImpl allocate, virDomainNetNotifyActualDeviceImpl notify, virDomainNetReleaseActualDeviceImpl release, virDomainNetBandwidthChangeAllowedImpl bandwidth= ChangeAllowed, - virDomainNetBandwidthUpdateImpl bandwidthUpdate); + virDomainNetBandwidthUpdateImpl bandwidthUpdate, + virDomainNetResolveActualTypeImpl resolveActualT= ype); =20 int virDomainNetAllocateActualDevice(virDomainDefPtr dom, @@ -3494,5 +3498,14 @@ virDomainNetBandwidthUpdate(virDomainNetDefPtr iface, virNetDevBandwidthPtr newBandwidth) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); =20 +/* XXX this is a nasty hack and should be removed. It should + * be by via public API by fetching XML and parsing it. Not + * easy right now as code paths in QEMU reying on this don't + * have a virConnectPtr handy. + */ +int +virDomainNetResolveActualType(virDomainNetDefPtr iface) + ATTRIBUTE_NONNULL(1); + =20 #endif /* __DOMAIN_CONF_H */ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 10d8e65b62..fc68c9d33e 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -456,6 +456,7 @@ virDomainNetNotifyActualDevice; virDomainNetReleaseActualDevice; virDomainNetRemove; virDomainNetRemoveHostdev; +virDomainNetResolveActualType; virDomainNetSetDeviceImpl; virDomainNetTypeFromString; virDomainNetTypeSharesHostView; diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index ee200f1343..76747670e9 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -5105,8 +5105,7 @@ networkReleaseActualDevice(virDomainDefPtr dom, =20 =20 =20 -/* networkGetActualType: - * @dom: domain definition that @iface belongs to +/* networkResolveActualType: * @iface: the original NetDef from the domain * * Looks up the network reference by iface, and returns the actual @@ -5114,8 +5113,8 @@ networkReleaseActualDevice(virDomainDefPtr dom, * * Returns 0 on success, -1 on failure. */ -int -networkGetActualType(virDomainNetDefPtr iface) +static int +networkResolveActualType(virDomainNetDefPtr iface) { virNetworkDriverStatePtr driver =3D networkGetDriver(); virNetworkObjPtr obj =3D NULL; @@ -5622,7 +5621,8 @@ networkRegister(void) networkNotifyActualDevice, networkReleaseActualDevice, networkBandwidthChangeAllowed, - networkBandwidthUpdate); + networkBandwidthUpdate, + networkResolveActualType); =20 return 0; } diff --git a/src/network/bridge_driver.h b/src/network/bridge_driver.h index 6fa6432d13..2cf886a7e6 100644 --- a/src/network/bridge_driver.h +++ b/src/network/bridge_driver.h @@ -36,10 +36,6 @@ networkRegister(void); =20 # if WITH_NETWORK =20 -int -networkGetActualType(virDomainNetDefPtr iface) - ATTRIBUTE_NONNULL(1); - int networkDnsmasqConfContents(virNetworkObjPtr obj, const char *pidfile, @@ -49,7 +45,6 @@ networkDnsmasqConfContents(virNetworkObjPtr obj, =20 # else /* Define no-op replacements that don't drag in any link dependencies. */ -# define networkGetActualType(iface) (iface->type) # define networkDnsmasqConfContents(network, pidfile, configstr, \ dctx, caps) 0 =20 diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c index 37fe2aa802..f44645c0af 100644 --- a/src/qemu/qemu_alias.c +++ b/src/qemu/qemu_alias.c @@ -275,7 +275,7 @@ qemuAssignDeviceNetAlias(virDomainDefPtr def, * We must use "-1" as the index because the caller doesn't know * that we're now looking for a unique hostdevN rather than netN */ - if (networkGetActualType(net) =3D=3D VIR_DOMAIN_NET_TYPE_HOSTDEV) + if (virDomainNetResolveActualType(net) =3D=3D VIR_DOMAIN_NET_TYPE_HOST= DEV) return qemuAssignDeviceHostdevAlias(def, &net->info.alias, -1); =20 if (idx =3D=3D -1) { diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 600de85f87..5e8b4a2066 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -1053,7 +1053,7 @@ qemuDomainFillDeviceIsolationGroup(virDomainDefPtr de= f, * to is of type hostdev. All other kinds of network interfaces do= n't * require us to isolate the guest device, so we can skip them */ if (iface->type !=3D VIR_DOMAIN_NET_TYPE_NETWORK || - networkGetActualType(iface) !=3D VIR_DOMAIN_NET_TYPE_HOSTDEV) { + virDomainNetResolveActualType(iface) !=3D VIR_DOMAIN_NET_TYPE_= HOSTDEV) { goto skip; } =20 --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 18:41:09 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1516873139478617.3765871453314; Thu, 25 Jan 2018 01:38:59 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9978B81DFB; Thu, 25 Jan 2018 09:38:58 +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 654F81801B; Thu, 25 Jan 2018 09:38:58 +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 C0C2118033E7; Thu, 25 Jan 2018 09:38:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0P9cu6B003218 for ; Thu, 25 Jan 2018 04:38:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6EF196031B; Thu, 25 Jan 2018 09:38:56 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 56BEE6056B; Thu, 25 Jan 2018 09:38:53 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 25 Jan 2018 09:38:19 +0000 Message-Id: <20180125093825.5834-9-berrange@redhat.com> In-Reply-To: <20180125093825.5834-1-berrange@redhat.com> References: <20180125093825.5834-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 08/14] network: remove conditional declarations 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 25 Jan 2018 09:38:59 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 The networkDnsmasqConfContents() method is only used by the test suite and that's only built with WITH_NETWORK is set. So there is no longer any reason to conditionalize the declaration of this method. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/network/bridge_driver.h | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/network/bridge_driver.h b/src/network/bridge_driver.h index 2cf886a7e6..b70881a690 100644 --- a/src/network/bridge_driver.h +++ b/src/network/bridge_driver.h @@ -34,8 +34,6 @@ int networkRegister(void); =20 -# if WITH_NETWORK - int networkDnsmasqConfContents(virNetworkObjPtr obj, const char *pidfile, @@ -43,11 +41,4 @@ networkDnsmasqConfContents(virNetworkObjPtr obj, dnsmasqContext *dctx, dnsmasqCapsPtr caps); =20 -# else -/* Define no-op replacements that don't drag in any link dependencies. */ -# define networkDnsmasqConfContents(network, pidfile, configstr, \ - dctx, caps) 0 - -# endif - #endif /* __VIR_NETWORK__DRIVER_H */ --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 18:41:09 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1516873143668567.1092185133587; Thu, 25 Jan 2018 01:39:03 -0800 (PST) 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 A4FD1A0C53; Thu, 25 Jan 2018 09:39:02 +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 712F52C317; Thu, 25 Jan 2018 09:39:02 +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 18D3018033EA; Thu, 25 Jan 2018 09:39:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0P9d0I4003240 for ; Thu, 25 Jan 2018 04:39:00 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5DD566056B; Thu, 25 Jan 2018 09:39:00 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4FF7E605DC; Thu, 25 Jan 2018 09:38:56 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 25 Jan 2018 09:38:20 +0000 Message-Id: <20180125093825.5834-10-berrange@redhat.com> In-Reply-To: <20180125093825.5834-1-berrange@redhat.com> References: <20180125093825.5834-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 09/14] conf: move virStorageTranslateDiskSourcePool into domain conf 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 25 Jan 2018 09:39:03 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 The virStorageTranslateDiskSourcePool method modifies a virDomainDiskDef to resolve any storage pool reference. For some reason this was added into the storage driver code, despite working entirely in terms of the public APIs. Move it into the domain conf file and rename it to match the object it modifies. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/bhyve/bhyve_command.c | 6 +- src/conf/domain_conf.c | 253 +++++++++++++++++++++++++++++++++++++++= ++++ src/conf/domain_conf.h | 4 + src/libvirt_private.syms | 1 + src/qemu/qemu_driver.c | 8 +- src/qemu/qemu_hotplug.c | 2 +- src/qemu/qemu_process.c | 4 +- src/storage/storage_driver.c | 251 ---------------------------------------= --- src/storage/storage_driver.h | 3 - 9 files changed, 268 insertions(+), 264 deletions(-) diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index 55032ae1df..5853a59372 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -199,7 +199,7 @@ bhyveBuildAHCIControllerArgStr(const virDomainDef *def, goto error; } =20 - if (virStorageTranslateDiskSourcePool(conn, disk) < 0) + if (virDomainDiskTranslateSourcePool(conn, disk) < 0) goto error; =20 disk_source =3D virDomainDiskGetSource(disk); @@ -295,7 +295,7 @@ bhyveBuildVirtIODiskArgStr(const virDomainDef *def ATTR= IBUTE_UNUSED, { const char *disk_source; =20 - if (virStorageTranslateDiskSourcePool(conn, disk) < 0) + if (virDomainDiskTranslateSourcePool(conn, disk) < 0) return -1; =20 if (disk->device !=3D VIR_DOMAIN_DISK_DEVICE_DISK) { @@ -676,7 +676,7 @@ static bool virBhyveUsableDisk(virConnectPtr conn, virDomainDiskDefPtr disk) { =20 - if (virStorageTranslateDiskSourcePool(conn, disk) < 0) + if (virDomainDiskTranslateSourcePool(conn, disk) < 0) return false; =20 if ((disk->device !=3D VIR_DOMAIN_DISK_DEVICE_DISK) && diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 05892c30d9..3d3104bb86 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -28544,3 +28544,256 @@ virDomainNetResolveActualType(virDomainNetDefPtr = iface) =20 return netResolveActualType(iface); } + + +static int +virDomainDiskAddISCSIPoolSourceHost(virDomainDiskDefPtr def, + virStoragePoolDefPtr pooldef) +{ + int ret =3D -1; + char **tokens =3D NULL; + + /* Only support one host */ + if (pooldef->source.nhost !=3D 1) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Expected exactly 1 host for the storage pool")); + goto cleanup; + } + + /* iscsi pool only supports one host */ + def->src->nhosts =3D 1; + + if (VIR_ALLOC_N(def->src->hosts, def->src->nhosts) < 0) + goto cleanup; + + if (VIR_STRDUP(def->src->hosts[0].name, pooldef->source.hosts[0].name)= < 0) + goto cleanup; + + def->src->hosts[0].port =3D pooldef->source.hosts[0].port ? + pooldef->source.hosts[0].port : 3260; + + /* iscsi volume has name like "unit:0:0:1" */ + if (!(tokens =3D virStringSplit(def->src->srcpool->volume, ":", 0))) + goto cleanup; + + if (virStringListLength((const char * const *)tokens) !=3D 4) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected iscsi volume name '%s'"), + def->src->srcpool->volume); + goto cleanup; + } + + /* iscsi pool has only one source device path */ + if (virAsprintf(&def->src->path, "%s/%s", + pooldef->source.devices[0].path, + tokens[3]) < 0) + goto cleanup; + + /* Storage pool have not supported these 2 attributes yet, + * use the defaults. + */ + def->src->hosts[0].transport =3D VIR_STORAGE_NET_HOST_TRANS_TCP; + def->src->hosts[0].socket =3D NULL; + + def->src->protocol =3D VIR_STORAGE_NET_PROTOCOL_ISCSI; + + ret =3D 0; + + cleanup: + virStringListFree(tokens); + return ret; +} + + +static int +virDomainDiskTranslateSourcePoolAuth(virDomainDiskDefPtr def, + virStoragePoolSourcePtr source) +{ + int ret =3D -1; + + /* Only necessary when authentication set */ + if (!source->auth) { + ret =3D 0; + goto cleanup; + } + def->src->auth =3D virStorageAuthDefCopy(source->auth); + if (!def->src->auth) + goto cleanup; + /* A doesn't use src->auth->authType =3D VIR_STORAGE_AUTH_TYPE_NONE; + ret =3D 0; + + cleanup: + return ret; +} + + +int +virDomainDiskTranslateSourcePool(virConnectPtr conn, + virDomainDiskDefPtr def) +{ + virStoragePoolDefPtr pooldef =3D NULL; + virStoragePoolPtr pool =3D NULL; + virStorageVolPtr vol =3D NULL; + char *poolxml =3D NULL; + virStorageVolInfo info; + int ret =3D -1; + + if (def->src->type !=3D VIR_STORAGE_TYPE_VOLUME) + return 0; + + if (!def->src->srcpool) + return 0; + + if (!(pool =3D virStoragePoolLookupByName(conn, def->src->srcpool->poo= l))) + return -1; + + if (virStoragePoolIsActive(pool) !=3D 1) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("storage pool '%s' containing volume '%s' " + "is not active"), + def->src->srcpool->pool, def->src->srcpool->volume); + goto cleanup; + } + + if (!(vol =3D virStorageVolLookupByName(pool, def->src->srcpool->volum= e))) + goto cleanup; + + if (virStorageVolGetInfo(vol, &info) < 0) + goto cleanup; + + if (!(poolxml =3D virStoragePoolGetXMLDesc(pool, 0))) + goto cleanup; + + if (!(pooldef =3D virStoragePoolDefParseString(poolxml))) + goto cleanup; + + def->src->srcpool->pooltype =3D pooldef->type; + def->src->srcpool->voltype =3D info.type; + + if (def->src->srcpool->mode && pooldef->type !=3D VIR_STORAGE_POOL_ISC= SI) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("disk source mode is only valid when " + "storage pool is of iscsi type")); + goto cleanup; + } + + VIR_FREE(def->src->path); + virStorageNetHostDefFree(def->src->nhosts, def->src->hosts); + def->src->nhosts =3D 0; + def->src->hosts =3D NULL; + virStorageAuthDefFree(def->src->auth); + def->src->auth =3D NULL; + + switch ((virStoragePoolType) pooldef->type) { + case VIR_STORAGE_POOL_DIR: + case VIR_STORAGE_POOL_FS: + case VIR_STORAGE_POOL_NETFS: + case VIR_STORAGE_POOL_LOGICAL: + case VIR_STORAGE_POOL_DISK: + case VIR_STORAGE_POOL_SCSI: + case VIR_STORAGE_POOL_ZFS: + case VIR_STORAGE_POOL_VSTORAGE: + if (!(def->src->path =3D virStorageVolGetPath(vol))) + goto cleanup; + + if (def->startupPolicy && info.type !=3D VIR_STORAGE_VOL_FILE) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("'startupPolicy' is only valid for " + "'file' type volume")); + goto cleanup; + } + + + switch (info.type) { + case VIR_STORAGE_VOL_FILE: + def->src->srcpool->actualtype =3D VIR_STORAGE_TYPE_FILE; + break; + + case VIR_STORAGE_VOL_DIR: + def->src->srcpool->actualtype =3D VIR_STORAGE_TYPE_DIR; + break; + + case VIR_STORAGE_VOL_BLOCK: + def->src->srcpool->actualtype =3D VIR_STORAGE_TYPE_BLOCK; + break; + + case VIR_STORAGE_VOL_PLOOP: + def->src->srcpool->actualtype =3D VIR_STORAGE_TYPE_FILE; + break; + + case VIR_STORAGE_VOL_NETWORK: + case VIR_STORAGE_VOL_NETDIR: + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected storage volume type '%s' " + "for storage pool type '%s'"), + virStorageVolTypeToString(info.type), + virStoragePoolTypeToString(pooldef->type)); + goto cleanup; + } + + break; + + case VIR_STORAGE_POOL_ISCSI: + if (def->startupPolicy) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("'startupPolicy' is only valid for " + "'file' type volume")); + goto cleanup; + } + + switch (def->src->srcpool->mode) { + case VIR_STORAGE_SOURCE_POOL_MODE_DEFAULT: + case VIR_STORAGE_SOURCE_POOL_MODE_LAST: + def->src->srcpool->mode =3D VIR_STORAGE_SOURCE_POOL_MODE_HOST; + ATTRIBUTE_FALLTHROUGH; + case VIR_STORAGE_SOURCE_POOL_MODE_HOST: + def->src->srcpool->actualtype =3D VIR_STORAGE_TYPE_BLOCK; + if (!(def->src->path =3D virStorageVolGetPath(vol))) + goto cleanup; + break; + + case VIR_STORAGE_SOURCE_POOL_MODE_DIRECT: + def->src->srcpool->actualtype =3D VIR_STORAGE_TYPE_NETWORK; + def->src->protocol =3D VIR_STORAGE_NET_PROTOCOL_ISCSI; + + if (virDomainDiskTranslateSourcePoolAuth(def, + &pooldef->source) < 0) + goto cleanup; + + /* Source pool may not fill in the secrettype field, + * so we need to do so here + */ + if (def->src->auth && !def->src->auth->secrettype) { + const char *secrettype =3D + virSecretUsageTypeToString(VIR_SECRET_USAGE_TYPE_ISCSI); + if (VIR_STRDUP(def->src->auth->secrettype, secrettype) < 0) + goto cleanup; + } + + if (virDomainDiskAddISCSIPoolSourceHost(def, pooldef) < 0) + goto cleanup; + break; + } + break; + + case VIR_STORAGE_POOL_MPATH: + case VIR_STORAGE_POOL_RBD: + case VIR_STORAGE_POOL_SHEEPDOG: + case VIR_STORAGE_POOL_GLUSTER: + case VIR_STORAGE_POOL_LAST: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("using '%s' pools for backing 'volume' disks " + "isn't yet supported"), + virStoragePoolTypeToString(pooldef->type)); + goto cleanup; + } + + ret =3D 0; + cleanup: + virObjectUnref(pool); + virObjectUnref(vol); + VIR_FREE(poolxml); + virStoragePoolDefFree(pooldef); + return ret; +} diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index d1f4038295..90e0b8d41e 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3508,4 +3508,8 @@ virDomainNetResolveActualType(virDomainNetDefPtr ifac= e) ATTRIBUTE_NONNULL(1); =20 =20 +int virDomainDiskTranslateSourcePool(virConnectPtr conn, + virDomainDiskDefPtr def); + + #endif /* __DOMAIN_CONF_H */ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index fc68c9d33e..7ebd0f6066 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -344,6 +344,7 @@ virDomainDiskSetDriver; virDomainDiskSetFormat; virDomainDiskSetSource; virDomainDiskSetType; +virDomainDiskTranslateSourcePool; virDomainFSDefFree; virDomainFSDefNew; virDomainFSIndexByName; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index a2a4c984df..fde2525b7d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7838,7 +7838,7 @@ qemuDomainChangeDiskLive(virConnectPtr conn, virDomainDiskDefPtr orig_disk =3D NULL; int ret =3D -1; =20 - if (virStorageTranslateDiskSourcePool(conn, disk) < 0) + if (virDomainDiskTranslateSourcePool(conn, disk) < 0) goto cleanup; =20 if (qemuDomainDetermineDiskChain(driver, vm, disk, false, true) < 0) @@ -7965,7 +7965,7 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, _("target %s already exists"), disk->dst); return -1; } - if (virStorageTranslateDiskSourcePool(conn, disk) < 0) + if (virDomainDiskTranslateSourcePool(conn, disk) < 0) return -1; if (qemuCheckDiskConfig(disk, NULL) < 0) return -1; @@ -14121,7 +14121,7 @@ qemuDomainSnapshotPrepareDiskExternal(virConnectPtr= conn, return -1; =20 if (!active) { - if (virStorageTranslateDiskSourcePool(conn, disk) < 0) + if (virDomainDiskTranslateSourcePool(conn, disk) < 0) return -1; =20 if (qemuDomainSnapshotPrepareDiskExternalInactive(snapdisk, disk) = < 0) @@ -14173,7 +14173,7 @@ qemuDomainSnapshotPrepareDiskInternal(virConnectPtr= conn, if (active) return 0; =20 - if (virStorageTranslateDiskSourcePool(conn, disk) < 0) + if (virDomainDiskTranslateSourcePool(conn, disk) < 0) return -1; =20 actualType =3D virStorageSourceGetActualType(disk->src); diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 2ab60919bb..cb28dc6808 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -711,7 +711,7 @@ qemuDomainAttachDeviceDiskLive(virConnectPtr conn, goto cleanup; } =20 - if (virStorageTranslateDiskSourcePool(conn, disk) < 0) + if (virDomainDiskTranslateSourcePool(conn, disk) < 0) goto cleanup; =20 if (qemuAddSharedDevice(driver, dev, vm->def->name) < 0) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 2c352523fe..5230132a61 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5507,7 +5507,7 @@ qemuProcessPrepareDomainStorage(virConnectPtr conn, size_t idx =3D i - 1; virDomainDiskDefPtr disk =3D vm->def->disks[idx]; =20 - if (virStorageTranslateDiskSourcePool(conn, disk) < 0) { + if (virDomainDiskTranslateSourcePool(conn, disk) < 0) { if (qemuDomainCheckDiskStartupPolicy(driver, vm, idx, cold_boo= t) < 0) return -1; =20 @@ -7250,7 +7250,7 @@ qemuProcessReconnect(void *opaque) virDomainDiskDefPtr disk =3D obj->def->disks[i]; virDomainDeviceDef dev; =20 - if (virStorageTranslateDiskSourcePool(conn, disk) < 0) + if (virDomainDiskTranslateSourcePool(conn, disk) < 0) goto error; =20 /* backing chains need to be refreshed only if they could change */ diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 3b66d51719..25e563e8d6 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -2773,257 +2773,6 @@ storageRegisterAll(void) } =20 =20 -static int -virStorageAddISCSIPoolSourceHost(virDomainDiskDefPtr def, - virStoragePoolDefPtr pooldef) -{ - int ret =3D -1; - char **tokens =3D NULL; - - /* Only support one host */ - if (pooldef->source.nhost !=3D 1) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Expected exactly 1 host for the storage pool")); - goto cleanup; - } - - /* iscsi pool only supports one host */ - def->src->nhosts =3D 1; - - if (VIR_ALLOC_N(def->src->hosts, def->src->nhosts) < 0) - goto cleanup; - - if (VIR_STRDUP(def->src->hosts[0].name, pooldef->source.hosts[0].name)= < 0) - goto cleanup; - - def->src->hosts[0].port =3D pooldef->source.hosts[0].port ? - pooldef->source.hosts[0].port : 3260; - - /* iscsi volume has name like "unit:0:0:1" */ - if (!(tokens =3D virStringSplit(def->src->srcpool->volume, ":", 0))) - goto cleanup; - - if (virStringListLength((const char * const *)tokens) !=3D 4) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected iscsi volume name '%s'"), - def->src->srcpool->volume); - goto cleanup; - } - - /* iscsi pool has only one source device path */ - if (virAsprintf(&def->src->path, "%s/%s", - pooldef->source.devices[0].path, - tokens[3]) < 0) - goto cleanup; - - /* Storage pool have not supported these 2 attributes yet, - * use the defaults. - */ - def->src->hosts[0].transport =3D VIR_STORAGE_NET_HOST_TRANS_TCP; - def->src->hosts[0].socket =3D NULL; - - def->src->protocol =3D VIR_STORAGE_NET_PROTOCOL_ISCSI; - - ret =3D 0; - - cleanup: - virStringListFree(tokens); - return ret; -} - - -static int -virStorageTranslateDiskSourcePoolAuth(virDomainDiskDefPtr def, - virStoragePoolSourcePtr source) -{ - int ret =3D -1; - - /* Only necessary when authentication set */ - if (!source->auth) { - ret =3D 0; - goto cleanup; - } - def->src->auth =3D virStorageAuthDefCopy(source->auth); - if (!def->src->auth) - goto cleanup; - /* A doesn't use src->auth->authType =3D VIR_STORAGE_AUTH_TYPE_NONE; - ret =3D 0; - - cleanup: - return ret; -} - - -int -virStorageTranslateDiskSourcePool(virConnectPtr conn, - virDomainDiskDefPtr def) -{ - virStoragePoolDefPtr pooldef =3D NULL; - virStoragePoolPtr pool =3D NULL; - virStorageVolPtr vol =3D NULL; - char *poolxml =3D NULL; - virStorageVolInfo info; - int ret =3D -1; - - if (def->src->type !=3D VIR_STORAGE_TYPE_VOLUME) - return 0; - - if (!def->src->srcpool) - return 0; - - if (!(pool =3D virStoragePoolLookupByName(conn, def->src->srcpool->poo= l))) - return -1; - - if (virStoragePoolIsActive(pool) !=3D 1) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("storage pool '%s' containing volume '%s' " - "is not active"), - def->src->srcpool->pool, def->src->srcpool->volume); - goto cleanup; - } - - if (!(vol =3D virStorageVolLookupByName(pool, def->src->srcpool->volum= e))) - goto cleanup; - - if (virStorageVolGetInfo(vol, &info) < 0) - goto cleanup; - - if (!(poolxml =3D virStoragePoolGetXMLDesc(pool, 0))) - goto cleanup; - - if (!(pooldef =3D virStoragePoolDefParseString(poolxml))) - goto cleanup; - - def->src->srcpool->pooltype =3D pooldef->type; - def->src->srcpool->voltype =3D info.type; - - if (def->src->srcpool->mode && pooldef->type !=3D VIR_STORAGE_POOL_ISC= SI) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("disk source mode is only valid when " - "storage pool is of iscsi type")); - goto cleanup; - } - - VIR_FREE(def->src->path); - virStorageNetHostDefFree(def->src->nhosts, def->src->hosts); - def->src->nhosts =3D 0; - def->src->hosts =3D NULL; - virStorageAuthDefFree(def->src->auth); - def->src->auth =3D NULL; - - switch ((virStoragePoolType) pooldef->type) { - case VIR_STORAGE_POOL_DIR: - case VIR_STORAGE_POOL_FS: - case VIR_STORAGE_POOL_NETFS: - case VIR_STORAGE_POOL_LOGICAL: - case VIR_STORAGE_POOL_DISK: - case VIR_STORAGE_POOL_SCSI: - case VIR_STORAGE_POOL_ZFS: - case VIR_STORAGE_POOL_VSTORAGE: - if (!(def->src->path =3D virStorageVolGetPath(vol))) - goto cleanup; - - if (def->startupPolicy && info.type !=3D VIR_STORAGE_VOL_FILE) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("'startupPolicy' is only valid for " - "'file' type volume")); - goto cleanup; - } - - - switch (info.type) { - case VIR_STORAGE_VOL_FILE: - def->src->srcpool->actualtype =3D VIR_STORAGE_TYPE_FILE; - break; - - case VIR_STORAGE_VOL_DIR: - def->src->srcpool->actualtype =3D VIR_STORAGE_TYPE_DIR; - break; - - case VIR_STORAGE_VOL_BLOCK: - def->src->srcpool->actualtype =3D VIR_STORAGE_TYPE_BLOCK; - break; - - case VIR_STORAGE_VOL_PLOOP: - def->src->srcpool->actualtype =3D VIR_STORAGE_TYPE_FILE; - break; - - case VIR_STORAGE_VOL_NETWORK: - case VIR_STORAGE_VOL_NETDIR: - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected storage volume type '%s' " - "for storage pool type '%s'"), - virStorageVolTypeToString(info.type), - virStoragePoolTypeToString(pooldef->type)); - goto cleanup; - } - - break; - - case VIR_STORAGE_POOL_ISCSI: - if (def->startupPolicy) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("'startupPolicy' is only valid for " - "'file' type volume")); - goto cleanup; - } - - switch (def->src->srcpool->mode) { - case VIR_STORAGE_SOURCE_POOL_MODE_DEFAULT: - case VIR_STORAGE_SOURCE_POOL_MODE_LAST: - def->src->srcpool->mode =3D VIR_STORAGE_SOURCE_POOL_MODE_HOST; - ATTRIBUTE_FALLTHROUGH; - case VIR_STORAGE_SOURCE_POOL_MODE_HOST: - def->src->srcpool->actualtype =3D VIR_STORAGE_TYPE_BLOCK; - if (!(def->src->path =3D virStorageVolGetPath(vol))) - goto cleanup; - break; - - case VIR_STORAGE_SOURCE_POOL_MODE_DIRECT: - def->src->srcpool->actualtype =3D VIR_STORAGE_TYPE_NETWORK; - def->src->protocol =3D VIR_STORAGE_NET_PROTOCOL_ISCSI; - - if (virStorageTranslateDiskSourcePoolAuth(def, - &pooldef->source) < 0) - goto cleanup; - - /* Source pool may not fill in the secrettype field, - * so we need to do so here - */ - if (def->src->auth && !def->src->auth->secrettype) { - const char *secrettype =3D - virSecretUsageTypeToString(VIR_SECRET_USAGE_TYPE_ISCSI); - if (VIR_STRDUP(def->src->auth->secrettype, secrettype) < 0) - goto cleanup; - } - - if (virStorageAddISCSIPoolSourceHost(def, pooldef) < 0) - goto cleanup; - break; - } - break; - - case VIR_STORAGE_POOL_MPATH: - case VIR_STORAGE_POOL_RBD: - case VIR_STORAGE_POOL_SHEEPDOG: - case VIR_STORAGE_POOL_GLUSTER: - case VIR_STORAGE_POOL_LAST: - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("using '%s' pools for backing 'volume' disks " - "isn't yet supported"), - virStoragePoolTypeToString(pooldef->type)); - goto cleanup; - } - - ret =3D 0; - cleanup: - virObjectUnref(pool); - virObjectUnref(vol); - VIR_FREE(poolxml); - virStoragePoolDefFree(pooldef); - return ret; -} =20 =20 /* diff --git a/src/storage/storage_driver.h b/src/storage/storage_driver.h index fd2fae1ba2..c284bf520f 100644 --- a/src/storage/storage_driver.h +++ b/src/storage/storage_driver.h @@ -29,9 +29,6 @@ # include "domain_conf.h" # include "virstorageobj.h" =20 -int virStorageTranslateDiskSourcePool(virConnectPtr conn, - virDomainDiskDefPtr def); - virStoragePoolObjPtr virStoragePoolObjFindPoolByUUID(const unsigned char *= uuid) ATTRIBUTE_NONNULL(1); =20 --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 18:41:09 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1516873147427515.2753901851833; Thu, 25 Jan 2018 01:39:07 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 718DC8FAC1; Thu, 25 Jan 2018 09:39:06 +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 41CC860BF9; Thu, 25 Jan 2018 09:39:06 +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 003B35FBE7; Thu, 25 Jan 2018 09:39:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0P9d33N003260 for ; Thu, 25 Jan 2018 04:39:03 -0500 Received: by smtp.corp.redhat.com (Postfix) id 99A876056B; Thu, 25 Jan 2018 09:39:03 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 788BE605DC; Thu, 25 Jan 2018 09:39:00 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 25 Jan 2018 09:38:21 +0000 Message-Id: <20180125093825.5834-11-berrange@redhat.com> In-Reply-To: <20180125093825.5834-1-berrange@redhat.com> References: <20180125093825.5834-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 10/14] storage: export virStoragePoolLookupByTargetPath as a public API 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 25 Jan 2018 09:39:07 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 The storagePoolLookupByTargetPath() method in the storage driver is used by the QEMU driver during block migration. If there's a valid use case for this in the QEMU driver, then external apps likely have similar needs. Exposing it in the public API removes the direct dependancy from the QEMU driver to the storage driver. Signed-off-by: Daniel P. Berrang=C3=A9 --- include/libvirt/libvirt-storage.h | 2 ++ src/driver-storage.h | 5 +++++ src/libvirt-storage.c | 40 +++++++++++++++++++++++++++++++++++= ++++ src/libvirt_public.syms | 6 ++++++ src/qemu/qemu_migration.c | 2 +- src/remote/remote_driver.c | 1 + src/remote/remote_protocol.x | 17 ++++++++++++++++- src/remote_protocol-structs | 7 +++++++ src/storage/storage_driver.c | 5 +++++ 9 files changed, 83 insertions(+), 2 deletions(-) diff --git a/include/libvirt/libvirt-storage.h b/include/libvirt/libvirt-st= orage.h index 736e2e3b80..413d9f6c4c 100644 --- a/include/libvirt/libvirt-storage.h +++ b/include/libvirt/libvirt-storage.h @@ -264,6 +264,8 @@ virStoragePoolPtr virStoragePoolLookupByUUID = (virConnectPtr conn, virStoragePoolPtr virStoragePoolLookupByUUIDString(virConnectPtr con= n, const char *uuid); virStoragePoolPtr virStoragePoolLookupByVolume (virStorageVolPtr = vol); +virStoragePoolPtr virStoragePoolLookupByTargetPath(virConnectPtr con= n, + const char *path); =20 /* * Creating/destroying pools diff --git a/src/driver-storage.h b/src/driver-storage.h index 48e588a546..146eb88b2c 100644 --- a/src/driver-storage.h +++ b/src/driver-storage.h @@ -63,6 +63,10 @@ typedef virStoragePoolPtr typedef virStoragePoolPtr (*virDrvStoragePoolLookupByVolume)(virStorageVolPtr vol); =20 +typedef virStoragePoolPtr +(*virDrvStoragePoolLookupByTargetPath)(virConnectPtr conn, + const char *path); + typedef virStoragePoolPtr (*virDrvStoragePoolCreateXML)(virConnectPtr conn, const char *xmlDesc, @@ -236,6 +240,7 @@ struct _virStorageDriver { virDrvStoragePoolLookupByName storagePoolLookupByName; virDrvStoragePoolLookupByUUID storagePoolLookupByUUID; virDrvStoragePoolLookupByVolume storagePoolLookupByVolume; + virDrvStoragePoolLookupByTargetPath storagePoolLookupByTargetPath; virDrvStoragePoolCreateXML storagePoolCreateXML; virDrvStoragePoolDefineXML storagePoolDefineXML; virDrvStoragePoolBuild storagePoolBuild; diff --git a/src/libvirt-storage.c b/src/libvirt-storage.c index e4646cb80f..3845a5d55e 100644 --- a/src/libvirt-storage.c +++ b/src/libvirt-storage.c @@ -497,6 +497,46 @@ virStoragePoolLookupByVolume(virStorageVolPtr vol) } =20 =20 +/** + * virStoragePoolLookupByTargetPath: + * @conn: pointer to hypervisor connection + * @path: path at which the pool is exposed + * + * Fetch a storage pool which maps to a particular target directory. + * If more than one pool maps to the path, it is undefined which + * will be returned first. + * + * virStoragePoolFree should be used to free the resources after the + * storage pool object is no longer needed. + * + * Returns a virStoragePoolPtr object, or NULL if no matching pool is found + */ +virStoragePoolPtr +virStoragePoolLookupByTargetPath(virConnectPtr conn, + const char *path) +{ + VIR_DEBUG("conn=3D%p, path=3D%s", conn, NULLSTR(path)); + + virResetLastError(); + + virCheckConnectReturn(conn, NULL); + virCheckNonNullArgGoto(path, error); + + if (conn->storageDriver && conn->storageDriver->storagePoolLookupByTar= getPath) { + virStoragePoolPtr ret; + ret =3D conn->storageDriver->storagePoolLookupByTargetPath(conn, p= ath); + if (!ret) + goto error; + return ret; + } + + virReportUnsupportedError(); + + error: + virDispatchError(conn); + return NULL; +} + /** * virStoragePoolCreateXML: * @conn: pointer to hypervisor connection diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 0efde25a7f..7bb8b3dd16 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -779,4 +779,10 @@ LIBVIRT_3.9.0 { global: virDomainSetLifecycleAction; } LIBVIRT_3.7.0; + +LIBVIRT_4.1.0 { + global: + virStoragePoolLookupByTargetPath; +} LIBVIRT_3.9.0; + # .... define new API here using predicted next version number .... diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 1854900c9a..8301c76a19 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -329,7 +329,7 @@ qemuMigrationPrecreateDisk(virConnectPtr conn, *volName =3D '\0'; volName++; =20 - if (!(pool =3D storagePoolLookupByTargetPath(conn, basePath))) + if (!(pool =3D virStoragePoolLookupByTargetPath(conn, basePath))) goto cleanup; format =3D virStorageFileFormatTypeToString(disk->src->format); if (disk->src->format =3D=3D VIR_STORAGE_FILE_QCOW2) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index f8fa64af99..9ea726dc45 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -8556,6 +8556,7 @@ static virStorageDriver storage_driver =3D { .storagePoolLookupByName =3D remoteStoragePoolLookupByName, /* 0.4.1 */ .storagePoolLookupByUUID =3D remoteStoragePoolLookupByUUID, /* 0.4.1 */ .storagePoolLookupByVolume =3D remoteStoragePoolLookupByVolume, /* 0.4= .1 */ + .storagePoolLookupByTargetPath =3D remoteStoragePoolLookupByTargetPath= , /* 4.1.0 */ .storagePoolCreateXML =3D remoteStoragePoolCreateXML, /* 0.4.1 */ .storagePoolDefineXML =3D remoteStoragePoolDefineXML, /* 0.4.1 */ .storagePoolBuild =3D remoteStoragePoolBuild, /* 0.4.1 */ diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index 0aed25220d..9dbd497b2f 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -1761,6 +1761,14 @@ struct remote_storage_pool_lookup_by_volume_ret { remote_nonnull_storage_pool pool; }; =20 +struct remote_storage_pool_lookup_by_target_path_args { + remote_nonnull_string path; +}; + +struct remote_storage_pool_lookup_by_target_path_ret { + remote_nonnull_storage_pool pool; +}; + struct remote_storage_pool_create_xml_args { remote_nonnull_string xml; unsigned int flags; @@ -6120,5 +6128,12 @@ enum remote_procedure { * @generate: both * @acl: domain:write */ - REMOTE_PROC_DOMAIN_SET_LIFECYCLE_ACTION =3D 390 + REMOTE_PROC_DOMAIN_SET_LIFECYCLE_ACTION =3D 390, + + /** + * @generate: both + * @priority: high + * @acl: storage_pool:getattr + */ + REMOTE_PROC_STORAGE_POOL_LOOKUP_BY_TARGET_PATH =3D 391 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index 59b0acec69..f45aba27a2 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -1330,6 +1330,12 @@ struct remote_storage_pool_lookup_by_volume_args { struct remote_storage_pool_lookup_by_volume_ret { remote_nonnull_storage_pool pool; }; +struct remote_storage_pool_lookup_by_target_path_args { + remote_nonnull_string path; +}; +struct remote_storage_pool_lookup_by_target_path_ret { + remote_nonnull_storage_pool pool; +}; struct remote_storage_pool_create_xml_args { remote_nonnull_string xml; u_int flags; @@ -3262,4 +3268,5 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_MANAGED_SAVE_GET_XML_DESC =3D 388, REMOTE_PROC_DOMAIN_MANAGED_SAVE_DEFINE_XML =3D 389, REMOTE_PROC_DOMAIN_SET_LIFECYCLE_ACTION =3D 390, + REMOTE_PROC_STORAGE_POOL_LOOKUP_BY_TARGET_PATH =3D 391, }; diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 25e563e8d6..d43ad1826c 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -1628,6 +1628,9 @@ storagePoolLookupByTargetPath(virConnectPtr conn, storagePoolLookupByTargetPathCa= llback, cleanpath))) { def =3D virStoragePoolObjGetDef(obj); + if (virStoragePoolLookupByTargetPathEnsureACL(conn, def) < 0) + goto cleanup; + pool =3D virGetStoragePool(conn, def->name, def->uuid, NULL, NULL); virStoragePoolObjEndAPI(&obj); } @@ -1644,6 +1647,7 @@ storagePoolLookupByTargetPath(virConnectPtr conn, } } =20 + cleanup: VIR_FREE(cleanpath); return pool; } @@ -2701,6 +2705,7 @@ static virStorageDriver storageDriver =3D { .storagePoolLookupByName =3D storagePoolLookupByName, /* 0.4.0 */ .storagePoolLookupByUUID =3D storagePoolLookupByUUID, /* 0.4.0 */ .storagePoolLookupByVolume =3D storagePoolLookupByVolume, /* 0.4.0 */ + .storagePoolLookupByTargetPath =3D storagePoolLookupByTargetPath, /* 4= .1.0 */ .storagePoolCreateXML =3D storagePoolCreateXML, /* 0.4.0 */ .storagePoolDefineXML =3D storagePoolDefineXML, /* 0.4.0 */ .storagePoolBuild =3D storagePoolBuild, /* 0.4.0 */ --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 18:41:09 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1516873150433820.3177284855711; Thu, 25 Jan 2018 01:39:10 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 859395B2F9; Thu, 25 Jan 2018 09:39:09 +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 52E6860BE3; Thu, 25 Jan 2018 09:39:09 +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 E27425FBE5; Thu, 25 Jan 2018 09:39:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0P9d62N003277 for ; Thu, 25 Jan 2018 04:39:06 -0500 Received: by smtp.corp.redhat.com (Postfix) id E46D4605DC; Thu, 25 Jan 2018 09:39:06 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id B93C36031B; Thu, 25 Jan 2018 09:39:04 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 25 Jan 2018 09:38:22 +0000 Message-Id: <20180125093825.5834-12-berrange@redhat.com> In-Reply-To: <20180125093825.5834-1-berrange@redhat.com> References: <20180125093825.5834-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 11/14] build: explicitly link all modules with libvirt.so 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 25 Jan 2018 09:39:10 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The dlopened modules we currently build all use various symbols from libvirt.so, but don't actually link to it. They rely on the libvirtd daemon re-exporting the libvirt.so symbols. This means that at the time the modules are linked, they contain a huge number of undefined symbols. It also means that these undefined symbols are not versioned, so despite us providing a LIBVIRT_PRIVATE_XXXX version that intentionally changes on every release, the loadable modules could actually be loaded into any libvirtd regardless of version. This change explicitly links all modules against libvirt.so so that they don't rely on the re-export behave and can be fully resolved at build time. This will give us a stronger guarantee modules will actually be loadable at runtime and that we're using modules from the matched build. Signed-off-by: Daniel P. Berrange --- src/Makefile.am | 49 ++++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index ec2b4f631c..492bbac22e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1334,7 +1334,7 @@ noinst_LTLIBRARIES +=3D libvirt_driver_xen_impl.la libvirt_driver_xen_la_SOURCES =3D libvirt_driver_xen_la_LIBADD =3D libvirt_driver_xen_impl.la mod_LTLIBRARIES +=3D libvirt_driver_xen.la -libvirt_driver_xen_la_LIBADD +=3D ../gnulib/lib/libgnu.la +libvirt_driver_xen_la_LIBADD +=3D libvirt.la ../gnulib/lib/libgnu.la libvirt_driver_xen_la_LDFLAGS =3D -module -avoid-version $(AM_LDFLAGS) =20 libvirt_driver_xen_impl_la_CFLAGS =3D \ @@ -1380,7 +1380,7 @@ libvirt_driver_vbox_la_SOURCES =3D libvirt_driver_vbox_la_LIBADD =3D libvirt_driver_vbox_impl.la mod_LTLIBRARIES +=3D \ libvirt_driver_vbox.la -libvirt_driver_vbox_la_LIBADD +=3D ../gnulib/lib/libgnu.la +libvirt_driver_vbox_la_LIBADD +=3D libvirt.la ../gnulib/lib/libgnu.la libvirt_driver_vbox_la_LDFLAGS =3D -module -avoid-version $(AM_LDFLAGS) =20 libvirt_driver_vbox_impl_la_CFLAGS =3D \ @@ -1409,7 +1409,7 @@ noinst_LTLIBRARIES +=3D libvirt_driver_libxl_impl.la libvirt_driver_libxl_la_SOURCES =3D libvirt_driver_libxl_la_LIBADD =3D libvirt_driver_libxl_impl.la mod_LTLIBRARIES +=3D libvirt_driver_libxl.la -libvirt_driver_libxl_la_LIBADD +=3D ../gnulib/lib/libgnu.la +libvirt_driver_libxl_la_LIBADD +=3D libvirt.la ../gnulib/lib/libgnu.la libvirt_driver_libxl_la_LDFLAGS =3D -module -avoid-version $(AM_LDFLAGS) =20 libvirt_driver_libxl_impl_la_CFLAGS =3D \ @@ -1421,8 +1421,7 @@ libvirt_driver_libxl_impl_la_CFLAGS =3D \ $(AM_CFLAGS) libvirt_driver_libxl_impl_la_LDFLAGS =3D $(AM_LDFLAGS) libvirt_driver_libxl_impl_la_LIBADD =3D $(LIBXL_LIBS) \ - libvirt_xenconfig_libxl.la \ - libvirt_secret.la + libvirt_xenconfig_libxl.la libvirt_driver_libxl_impl_la_SOURCES =3D $(LIBXL_DRIVER_SOURCES) =20 conf_DATA +=3D libxl/libxl.conf @@ -1439,7 +1438,7 @@ noinst_LTLIBRARIES +=3D libvirt_driver_qemu_impl.la libvirt_driver_qemu_la_SOURCES =3D libvirt_driver_qemu_la_LIBADD =3D libvirt_driver_qemu_impl.la mod_LTLIBRARIES +=3D libvirt_driver_qemu.la -libvirt_driver_qemu_la_LIBADD +=3D ../gnulib/lib/libgnu.la +libvirt_driver_qemu_la_LIBADD +=3D libvirt.la ../gnulib/lib/libgnu.la libvirt_driver_qemu_la_LDFLAGS =3D -module -avoid-version $(AM_LDFLAGS) =20 libvirt_driver_qemu_impl_la_CFLAGS =3D \ @@ -1455,7 +1454,6 @@ libvirt_driver_qemu_impl_la_LIBADD =3D $(CAPNG_LIBS) \ $(GNUTLS_LIBS) \ $(LIBNL_LIBS) \ $(LIBXML_LIBS) \ - libvirt_secret.la \ $(NULL) libvirt_driver_qemu_impl_la_SOURCES =3D $(QEMU_DRIVER_SOURCES) =20 @@ -1475,7 +1473,7 @@ noinst_LTLIBRARIES +=3D libvirt_driver_lxc_impl.la libvirt_driver_lxc_la_SOURCES =3D libvirt_driver_lxc_la_LIBADD =3D libvirt_driver_lxc_impl.la mod_LTLIBRARIES +=3D libvirt_driver_lxc.la -libvirt_driver_lxc_la_LIBADD +=3D ../gnulib/lib/libgnu.la +libvirt_driver_lxc_la_LIBADD +=3D libvirt.la ../gnulib/lib/libgnu.la libvirt_driver_lxc_la_LDFLAGS =3D -module -avoid-version $(AM_LDFLAGS) =20 libvirt_driver_lxc_impl_la_CFLAGS =3D \ @@ -1512,7 +1510,7 @@ noinst_LTLIBRARIES +=3D libvirt_driver_uml_impl.la libvirt_driver_uml_la_SOURCES =3D libvirt_driver_uml_la_LIBADD =3D libvirt_driver_uml_impl.la mod_LTLIBRARIES +=3D libvirt_driver_uml.la -libvirt_driver_uml_la_LIBADD +=3D ../gnulib/lib/libgnu.la +libvirt_driver_uml_la_LIBADD +=3D libvirt.la ../gnulib/lib/libgnu.la libvirt_driver_uml_la_LDFLAGS =3D -module -avoid-version $(AM_LDFLAGS) =20 libvirt_driver_uml_impl_la_CFLAGS =3D \ @@ -1584,7 +1582,7 @@ noinst_LTLIBRARIES +=3D libvirt_driver_vz_impl.la libvirt_driver_vz_la_SOURCES =3D libvirt_driver_vz_la_LIBADD =3D libvirt_driver_vz_impl.la mod_LTLIBRARIES +=3D libvirt_driver_vz.la -libvirt_driver_vz_la_LIBADD +=3D ../gnulib/lib/libgnu.la +libvirt_driver_vz_la_LIBADD +=3D libvirt.la ../gnulib/lib/libgnu.la libvirt_driver_vz_la_LDFLAGS =3D -module -avoid-version $(AM_LDFLAGS) libvirt_driver_vz_impl_la_CFLAGS =3D \ -I$(srcdir)/conf \ @@ -1600,7 +1598,7 @@ noinst_LTLIBRARIES +=3D libvirt_driver_bhyve_impl.la libvirt_driver_bhyve_la_SOURCES =3D libvirt_driver_bhyve_la_LIBADD =3D libvirt_driver_bhyve_impl.la mod_LTLIBRARIES +=3D libvirt_driver_bhyve.la -libvirt_driver_bhyve_la_LIBADD +=3D ../gnulib/lib/libgnu.la +libvirt_driver_bhyve_la_LIBADD +=3D libvirt.la ../gnulib/lib/libgnu.la libvirt_driver_bhyve_la_LDFLAGS =3D -module -avoid-version $(AM_LDFLAGS) =20 libvirt_driver_bhyve_impl_la_CFLAGS =3D \ @@ -1623,7 +1621,7 @@ noinst_LTLIBRARIES +=3D libvirt_driver_network_impl.la libvirt_driver_network_la_SOURCES =3D libvirt_driver_network_la_LIBADD =3D libvirt_driver_network_impl.la mod_LTLIBRARIES +=3D libvirt_driver_network.la -libvirt_driver_network_la_LIBADD +=3D ../gnulib/lib/libgnu.la \ +libvirt_driver_network_la_LIBADD +=3D libvirt.la ../gnulib/lib/libgnu.la \ $(LIBNL_LIBS) \ $(DBUS_LIBS) \ $(NULL) @@ -1657,7 +1655,7 @@ if WITH_UDEV libvirt_driver_interface_la_CFLAGS +=3D $(UDEV_CFLAGS) libvirt_driver_interface_la_LIBADD +=3D $(UDEV_LIBS) endif WITH_UDEV -libvirt_driver_interface_la_LIBADD +=3D ../gnulib/lib/libgnu.la +libvirt_driver_interface_la_LIBADD +=3D libvirt.la ../gnulib/lib/libgnu.la libvirt_driver_interface_la_LDFLAGS +=3D -module -avoid-version libvirt_driver_interface_la_SOURCES =3D $(INTERFACE_DRIVER_SOURCES) endif WITH_INTERFACE @@ -1668,7 +1666,7 @@ libvirt_driver_secret_la_CFLAGS =3D \ -I$(srcdir)/access \ -I$(srcdir)/conf \ $(AM_CFLAGS) -libvirt_driver_secret_la_LIBADD =3D ../gnulib/lib/libgnu.la +libvirt_driver_secret_la_LIBADD =3D libvirt.la ../gnulib/lib/libgnu.la libvirt_driver_secret_la_LDFLAGS =3D -module -avoid-version $(AM_LDFLAGS) libvirt_driver_secret_la_SOURCES =3D $(SECRET_DRIVER_SOURCES) endif WITH_SECRETS @@ -1696,7 +1694,7 @@ noinst_LTLIBRARIES +=3D libvirt_driver_storage_impl.la libvirt_driver_storage_la_SOURCES =3D libvirt_driver_storage_la_LIBADD =3D libvirt_driver_storage_impl.la mod_LTLIBRARIES +=3D libvirt_driver_storage.la -libvirt_driver_storage_la_LIBADD +=3D ../gnulib/lib/libgnu.la +libvirt_driver_storage_la_LIBADD +=3D libvirt.la ../gnulib/lib/libgnu.la libvirt_driver_storage_la_LDFLAGS =3D -module -avoid-version $(AM_LDFLAGS) libvirt_driver_storage_impl_la_SOURCES +=3D $(STORAGE_DRIVER_SOURCES) =20 @@ -1709,6 +1707,7 @@ libvirt_storage_backend_fs_la_CFLAGS =3D \ storagebackend_LTLIBRARIES +=3D libvirt_storage_backend_fs.la libvirt_storage_backend_fs_la_LDFLAGS =3D \ -module -avoid-version $(AM_LDFLAGS) +libvirt_storage_backend_fs_la_LIBADD =3D libvirt.la ../gnulib/lib/libgnu.la endif WITH_STORAGE =20 if WITH_STORAGE_LVM @@ -1721,6 +1720,7 @@ libvirt_storage_backend_logical_la_CFLAGS =3D \ storagebackend_LTLIBRARIES +=3D libvirt_storage_backend_logical.la libvirt_storage_backend_logical_la_LDFLAGS =3D \ -module -avoid-version $(AM_LDFLAGS) +libvirt_storage_backend_logical_la_LIBADD =3D libvirt.la ../gnulib/lib/lib= gnu.la endif WITH_STORAGE_LVM =20 if WITH_STORAGE_ISCSI @@ -1734,6 +1734,7 @@ libvirt_storage_backend_iscsi_la_CFLAGS =3D \ storagebackend_LTLIBRARIES +=3D libvirt_storage_backend_iscsi.la libvirt_storage_backend_iscsi_la_LDFLAGS =3D \ -module -avoid-version $(AM_LDFLAGS) +libvirt_storage_backend_iscsi_la_LIBADD =3D libvirt.la ../gnulib/lib/libgn= u.la endif WITH_STORAGE_ISCSI =20 if WITH_STORAGE_SCSI @@ -1745,6 +1746,7 @@ libvirt_storage_backend_scsi_la_CFLAGS =3D \ storagebackend_LTLIBRARIES +=3D libvirt_storage_backend_scsi.la libvirt_storage_backend_scsi_la_LDFLAGS =3D \ -module -avoid-version $(AM_LDFLAGS) +libvirt_storage_backend_scsi_la_LIBADD =3D libvirt.la ../gnulib/lib/libgnu= .la endif WITH_STORAGE_SCSI =20 if WITH_STORAGE_MPATH @@ -1759,6 +1761,7 @@ libvirt_storage_backend_mpath_la_CFLAGS =3D \ storagebackend_LTLIBRARIES +=3D libvirt_storage_backend_mpath.la libvirt_storage_backend_mpath_la_LDFLAGS =3D \ -module -avoid-version $(AM_LDFLAGS) +libvirt_storage_backend_mpath_la_LIBADD +=3D libvirt.la ../gnulib/lib/libg= nu.la endif WITH_STORAGE_MPATH =20 if WITH_STORAGE_DISK @@ -1770,6 +1773,7 @@ libvirt_storage_backend_disk_la_CFLAGS =3D \ storagebackend_LTLIBRARIES +=3D libvirt_storage_backend_disk.la libvirt_storage_backend_disk_la_LDFLAGS =3D \ -module -avoid-version $(AM_LDFLAGS) +libvirt_storage_backend_disk_la_LIBADD =3D libvirt.la ../gnulib/lib/libgnu= .la endif WITH_STORAGE_DISK =20 if WITH_STORAGE_RBD @@ -1783,6 +1787,7 @@ libvirt_storage_backend_rbd_la_CFLAGS =3D \ storagebackend_LTLIBRARIES +=3D libvirt_storage_backend_rbd.la libvirt_storage_backend_rbd_la_LDFLAGS =3D \ -module -avoid-version $(AM_LDFLAGS) +libvirt_storage_backend_rbd_la_LIBADD +=3D libvirt.la ../gnulib/lib/libgnu= .la endif WITH_STORAGE_RBD =20 if WITH_STORAGE_SHEEPDOG @@ -1803,6 +1808,7 @@ noinst_LTLIBRARIES +=3D libvirt_storage_backend_sheep= dog_priv.la storagebackend_LTLIBRARIES +=3D libvirt_storage_backend_sheepdog.la libvirt_storage_backend_sheepdog_la_LDFLAGS =3D \ -module -avoid-version $(AM_LDFLAGS) +libvirt_storage_backend_sheepdog_la_LIBADD =3D libvirt.la ../gnulib/lib/li= bgnu.la endif WITH_STORAGE_SHEEPDOG =20 if WITH_STORAGE_GLUSTER @@ -1817,6 +1823,7 @@ libvirt_storage_backend_gluster_la_CFLAGS =3D \ storagebackend_LTLIBRARIES +=3D libvirt_storage_backend_gluster.la libvirt_storage_backend_gluster_la_LDFLAGS =3D \ -module -avoid-version $(AM_LDFLAGS) +libvirt_storage_backend_gluster_la_LIBADD +=3D libvirt.la ../gnulib/lib/li= bgnu.la endif WITH_STORAGE_GLUSTER =20 if WITH_STORAGE_ZFS @@ -1828,6 +1835,7 @@ libvirt_storage_backend_zfs_la_CFLAGS =3D \ storagebackend_LTLIBRARIES +=3D libvirt_storage_backend_zfs.la libvirt_storage_backend_zfs_la_LDFLAGS =3D \ -module -avoid-version $(AM_LDFLAGS) +libvirt_storage_backend_zfs_la_LIBADD =3D libvirt.la ../gnulib/lib/libgnu.= la endif WITH_STORAGE_ZFS =20 if WITH_STORAGE_VSTORAGE @@ -1840,6 +1848,7 @@ libvirt_storage_backend_vstorage_la_CFLAGS =3D \ storagebackend_LTLIBRARIES +=3D libvirt_storage_backend_vstorage.la libvirt_storage_backend_vstorage_la_LDFLAGS =3D \ -module -avoid-version $(AM_LDFLAGS) +libvirt_storage_backend_vstorage_la_LIBADD =3D libvirt.la ../gnulib/lib/li= bgnu.la endif WITH_STORAGE_VSTORAGE =20 if WITH_NODE_DEVICES @@ -1867,7 +1876,7 @@ libvirt_driver_nodedev_la_LIBADD +=3D $(UDEV_LIBS) $(= PCIACCESS_LIBS) endif WITH_UDEV endif WITH_LIBVIRTD =20 -libvirt_driver_nodedev_la_LIBADD +=3D ../gnulib/lib/libgnu.la +libvirt_driver_nodedev_la_LIBADD +=3D libvirt.la ../gnulib/lib/libgnu.la libvirt_driver_nodedev_la_LDFLAGS +=3D -module -avoid-version endif WITH_NODE_DEVICES =20 @@ -1890,7 +1899,7 @@ libvirt_driver_nwfilter_impl_la_LIBADD =3D \ $(LIBPCAP_LIBS) \ $(LIBNL_LIBS) \ $(DBUS_LIBS) -libvirt_driver_nwfilter_impl_la_LIBADD +=3D ../gnulib/lib/libgnu.la +libvirt_driver_nwfilter_impl_la_LIBADD +=3D libvirt.la ../gnulib/lib/libgn= u.la libvirt_driver_nwfilter_impl_la_LDFLAGS +=3D -module -avoid-version libvirt_driver_nwfilter_impl_la_SOURCES =3D $(NWFILTER_DRIVER_SOURCES) endif WITH_NWFILTER @@ -2568,8 +2577,7 @@ lockd_la_CFLAGS =3D -I$(srcdir)/conf \ $(XDR_CFLAGS) \ $(AM_CFLAGS) lockd_la_LDFLAGS =3D -module -avoid-version $(AM_LDFLAGS) -lockd_la_LIBADD =3D ../gnulib/lib/libgnu.la \ - $(NULL) +lockd_la_LIBADD =3D libvirt.la ../gnulib/lib/libgnu.la augeas_DATA +=3D locking/libvirt_lockd.aug if WITH_DTRACE_PROBES lockd_la_LIBADD +=3D libvirt_probes.lo @@ -2848,8 +2856,7 @@ lockdriver_LTLIBRARIES +=3D sanlock.la sanlock_la_SOURCES =3D $(LOCK_DRIVER_SANLOCK_SOURCES) sanlock_la_CFLAGS =3D -I$(srcdir)/conf $(AM_CFLAGS) sanlock_la_LDFLAGS =3D -module -avoid-version $(AM_LDFLAGS) -sanlock_la_LIBADD =3D -lsanlock_client \ - ../gnulib/lib/libgnu.la +sanlock_la_LIBADD =3D -lsanlock_client libvirt.la ../gnulib/lib/libgnu.la =20 augeas_DATA +=3D locking/libvirt_sanlock.aug augeastest_DATA +=3D test_libvirt_sanlock.aug --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 18:41:09 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15168731595711018.3537515074628; Thu, 25 Jan 2018 01:39:19 -0800 (PST) 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 A29DD8FAC0; Thu, 25 Jan 2018 09:39:18 +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 5ED6D65606; Thu, 25 Jan 2018 09:39:18 +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 224FA62CE9; Thu, 25 Jan 2018 09:39:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0P9dGiD003338 for ; Thu, 25 Jan 2018 04:39:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id 87CEA605DC; Thu, 25 Jan 2018 09:39:16 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id EB0B06031B; Thu, 25 Jan 2018 09:39:07 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 25 Jan 2018 09:38:23 +0000 Message-Id: <20180125093825.5834-13-berrange@redhat.com> In-Reply-To: <20180125093825.5834-1-berrange@redhat.com> References: <20180125093825.5834-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 12/14] build: provide a AM_FLAGS_MOD for loadable modules 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 25 Jan 2018 09:39:19 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Dynamic loadable modules all need a common set of linker flags -module -avoid-version $(AM_LDFLAGS) Bundle those up into a $(AM_LDFLAGS_MOD) to avoid repetition. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/Makefile.am | 69 +++++++++++++++++++++++------------------------------= ---- 1 file changed, 28 insertions(+), 41 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 492bbac22e..335b3a0c81 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -51,6 +51,7 @@ AM_LDFLAGS =3D $(DRIVER_MODULES_LDFLAGS) \ $(CYGWIN_EXTRA_LDFLAGS) \ $(MINGW_EXTRA_LDFLAGS) \ $(NULL) +AM_LDFLAGS_MOD =3D -module -avoid-version $(AM_LDFLAGS) =20 POD2MAN =3D pod2man -c "Virtualization Support" -r "$(PACKAGE)-$(VERSION)" =20 @@ -1335,7 +1336,7 @@ libvirt_driver_xen_la_SOURCES =3D libvirt_driver_xen_la_LIBADD =3D libvirt_driver_xen_impl.la mod_LTLIBRARIES +=3D libvirt_driver_xen.la libvirt_driver_xen_la_LIBADD +=3D libvirt.la ../gnulib/lib/libgnu.la -libvirt_driver_xen_la_LDFLAGS =3D -module -avoid-version $(AM_LDFLAGS) +libvirt_driver_xen_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) =20 libvirt_driver_xen_impl_la_CFLAGS =3D \ $(XEN_CFLAGS) \ @@ -1381,7 +1382,7 @@ libvirt_driver_vbox_la_LIBADD =3D libvirt_driver_vbox= _impl.la mod_LTLIBRARIES +=3D \ libvirt_driver_vbox.la libvirt_driver_vbox_la_LIBADD +=3D libvirt.la ../gnulib/lib/libgnu.la -libvirt_driver_vbox_la_LDFLAGS =3D -module -avoid-version $(AM_LDFLAGS) +libvirt_driver_vbox_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) =20 libvirt_driver_vbox_impl_la_CFLAGS =3D \ -I$(srcdir)/conf \ @@ -1410,7 +1411,7 @@ libvirt_driver_libxl_la_SOURCES =3D libvirt_driver_libxl_la_LIBADD =3D libvirt_driver_libxl_impl.la mod_LTLIBRARIES +=3D libvirt_driver_libxl.la libvirt_driver_libxl_la_LIBADD +=3D libvirt.la ../gnulib/lib/libgnu.la -libvirt_driver_libxl_la_LDFLAGS =3D -module -avoid-version $(AM_LDFLAGS) +libvirt_driver_libxl_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) =20 libvirt_driver_libxl_impl_la_CFLAGS =3D \ $(LIBXL_CFLAGS) \ @@ -1439,7 +1440,7 @@ libvirt_driver_qemu_la_SOURCES =3D libvirt_driver_qemu_la_LIBADD =3D libvirt_driver_qemu_impl.la mod_LTLIBRARIES +=3D libvirt_driver_qemu.la libvirt_driver_qemu_la_LIBADD +=3D libvirt.la ../gnulib/lib/libgnu.la -libvirt_driver_qemu_la_LDFLAGS =3D -module -avoid-version $(AM_LDFLAGS) +libvirt_driver_qemu_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) =20 libvirt_driver_qemu_impl_la_CFLAGS =3D \ $(GNUTLS_CFLAGS) \ @@ -1474,7 +1475,7 @@ libvirt_driver_lxc_la_SOURCES =3D libvirt_driver_lxc_la_LIBADD =3D libvirt_driver_lxc_impl.la mod_LTLIBRARIES +=3D libvirt_driver_lxc.la libvirt_driver_lxc_la_LIBADD +=3D libvirt.la ../gnulib/lib/libgnu.la -libvirt_driver_lxc_la_LDFLAGS =3D -module -avoid-version $(AM_LDFLAGS) +libvirt_driver_lxc_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) =20 libvirt_driver_lxc_impl_la_CFLAGS =3D \ $(LIBNL_CFLAGS) \ @@ -1511,7 +1512,7 @@ libvirt_driver_uml_la_SOURCES =3D libvirt_driver_uml_la_LIBADD =3D libvirt_driver_uml_impl.la mod_LTLIBRARIES +=3D libvirt_driver_uml.la libvirt_driver_uml_la_LIBADD +=3D libvirt.la ../gnulib/lib/libgnu.la -libvirt_driver_uml_la_LDFLAGS =3D -module -avoid-version $(AM_LDFLAGS) +libvirt_driver_uml_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) =20 libvirt_driver_uml_impl_la_CFLAGS =3D \ -I$(srcdir)/access \ @@ -1583,7 +1584,7 @@ libvirt_driver_vz_la_SOURCES =3D libvirt_driver_vz_la_LIBADD =3D libvirt_driver_vz_impl.la mod_LTLIBRARIES +=3D libvirt_driver_vz.la libvirt_driver_vz_la_LIBADD +=3D libvirt.la ../gnulib/lib/libgnu.la -libvirt_driver_vz_la_LDFLAGS =3D -module -avoid-version $(AM_LDFLAGS) +libvirt_driver_vz_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) libvirt_driver_vz_impl_la_CFLAGS =3D \ -I$(srcdir)/conf \ -I$(srcdir)/access \ @@ -1599,7 +1600,7 @@ libvirt_driver_bhyve_la_SOURCES =3D libvirt_driver_bhyve_la_LIBADD =3D libvirt_driver_bhyve_impl.la mod_LTLIBRARIES +=3D libvirt_driver_bhyve.la libvirt_driver_bhyve_la_LIBADD +=3D libvirt.la ../gnulib/lib/libgnu.la -libvirt_driver_bhyve_la_LDFLAGS =3D -module -avoid-version $(AM_LDFLAGS) +libvirt_driver_bhyve_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) =20 libvirt_driver_bhyve_impl_la_CFLAGS =3D \ -I$(srcdir)/access \ @@ -1625,7 +1626,7 @@ libvirt_driver_network_la_LIBADD +=3D libvirt.la ../g= nulib/lib/libgnu.la \ $(LIBNL_LIBS) \ $(DBUS_LIBS) \ $(NULL) -libvirt_driver_network_la_LDFLAGS =3D -module -avoid-version $(AM_LDFLAGS) +libvirt_driver_network_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) =20 libvirt_driver_network_impl_la_CFLAGS =3D \ $(LIBNL_CFLAGS) \ @@ -1645,7 +1646,7 @@ libvirt_driver_interface_la_CFLAGS =3D \ -I$(srcdir)/access \ -I$(srcdir)/conf \ $(AM_CFLAGS) $(LIBNL_CFLAGS) -libvirt_driver_interface_la_LDFLAGS =3D $(AM_LDFLAGS) +libvirt_driver_interface_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) libvirt_driver_interface_la_LIBADD =3D if WITH_NETCF libvirt_driver_interface_la_CFLAGS +=3D $(NETCF_CFLAGS) @@ -1656,7 +1657,6 @@ libvirt_driver_interface_la_CFLAGS +=3D $(UDEV_CFLAGS) libvirt_driver_interface_la_LIBADD +=3D $(UDEV_LIBS) endif WITH_UDEV libvirt_driver_interface_la_LIBADD +=3D libvirt.la ../gnulib/lib/libgnu.la -libvirt_driver_interface_la_LDFLAGS +=3D -module -avoid-version libvirt_driver_interface_la_SOURCES =3D $(INTERFACE_DRIVER_SOURCES) endif WITH_INTERFACE =20 @@ -1667,7 +1667,7 @@ libvirt_driver_secret_la_CFLAGS =3D \ -I$(srcdir)/conf \ $(AM_CFLAGS) libvirt_driver_secret_la_LIBADD =3D libvirt.la ../gnulib/lib/libgnu.la -libvirt_driver_secret_la_LDFLAGS =3D -module -avoid-version $(AM_LDFLAGS) +libvirt_driver_secret_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) libvirt_driver_secret_la_SOURCES =3D $(SECRET_DRIVER_SOURCES) endif WITH_SECRETS =20 @@ -1695,7 +1695,7 @@ libvirt_driver_storage_la_SOURCES =3D libvirt_driver_storage_la_LIBADD =3D libvirt_driver_storage_impl.la mod_LTLIBRARIES +=3D libvirt_driver_storage.la libvirt_driver_storage_la_LIBADD +=3D libvirt.la ../gnulib/lib/libgnu.la -libvirt_driver_storage_la_LDFLAGS =3D -module -avoid-version $(AM_LDFLAGS) +libvirt_driver_storage_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) libvirt_driver_storage_impl_la_SOURCES +=3D $(STORAGE_DRIVER_SOURCES) =20 =20 @@ -1705,8 +1705,7 @@ libvirt_storage_backend_fs_la_CFLAGS =3D \ $(AM_CFLAGS) =20 storagebackend_LTLIBRARIES +=3D libvirt_storage_backend_fs.la -libvirt_storage_backend_fs_la_LDFLAGS =3D \ - -module -avoid-version $(AM_LDFLAGS) +libvirt_storage_backend_fs_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) libvirt_storage_backend_fs_la_LIBADD =3D libvirt.la ../gnulib/lib/libgnu.la endif WITH_STORAGE =20 @@ -1718,8 +1717,7 @@ libvirt_storage_backend_logical_la_CFLAGS =3D \ $(AM_CFLAGS) =20 storagebackend_LTLIBRARIES +=3D libvirt_storage_backend_logical.la -libvirt_storage_backend_logical_la_LDFLAGS =3D \ - -module -avoid-version $(AM_LDFLAGS) +libvirt_storage_backend_logical_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) libvirt_storage_backend_logical_la_LIBADD =3D libvirt.la ../gnulib/lib/lib= gnu.la endif WITH_STORAGE_LVM =20 @@ -1732,8 +1730,7 @@ libvirt_storage_backend_iscsi_la_CFLAGS =3D \ $(AM_CFLAGS) =20 storagebackend_LTLIBRARIES +=3D libvirt_storage_backend_iscsi.la -libvirt_storage_backend_iscsi_la_LDFLAGS =3D \ - -module -avoid-version $(AM_LDFLAGS) +libvirt_storage_backend_iscsi_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) libvirt_storage_backend_iscsi_la_LIBADD =3D libvirt.la ../gnulib/lib/libgn= u.la endif WITH_STORAGE_ISCSI =20 @@ -1744,8 +1741,7 @@ libvirt_storage_backend_scsi_la_CFLAGS =3D \ $(AM_CFLAGS) =20 storagebackend_LTLIBRARIES +=3D libvirt_storage_backend_scsi.la -libvirt_storage_backend_scsi_la_LDFLAGS =3D \ - -module -avoid-version $(AM_LDFLAGS) +libvirt_storage_backend_scsi_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) libvirt_storage_backend_scsi_la_LIBADD =3D libvirt.la ../gnulib/lib/libgnu= .la endif WITH_STORAGE_SCSI =20 @@ -1759,8 +1755,7 @@ libvirt_storage_backend_mpath_la_CFLAGS =3D \ $(AM_CFLAGS) =20 storagebackend_LTLIBRARIES +=3D libvirt_storage_backend_mpath.la -libvirt_storage_backend_mpath_la_LDFLAGS =3D \ - -module -avoid-version $(AM_LDFLAGS) +libvirt_storage_backend_mpath_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) libvirt_storage_backend_mpath_la_LIBADD +=3D libvirt.la ../gnulib/lib/libg= nu.la endif WITH_STORAGE_MPATH =20 @@ -1771,8 +1766,7 @@ libvirt_storage_backend_disk_la_CFLAGS =3D \ $(AM_CFLAGS) =20 storagebackend_LTLIBRARIES +=3D libvirt_storage_backend_disk.la -libvirt_storage_backend_disk_la_LDFLAGS =3D \ - -module -avoid-version $(AM_LDFLAGS) +libvirt_storage_backend_disk_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) libvirt_storage_backend_disk_la_LIBADD =3D libvirt.la ../gnulib/lib/libgnu= .la endif WITH_STORAGE_DISK =20 @@ -1785,8 +1779,7 @@ libvirt_storage_backend_rbd_la_CFLAGS =3D \ $(AM_CFLAGS) =20 storagebackend_LTLIBRARIES +=3D libvirt_storage_backend_rbd.la -libvirt_storage_backend_rbd_la_LDFLAGS =3D \ - -module -avoid-version $(AM_LDFLAGS) +libvirt_storage_backend_rbd_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) libvirt_storage_backend_rbd_la_LIBADD +=3D libvirt.la ../gnulib/lib/libgnu= .la endif WITH_STORAGE_RBD =20 @@ -1806,8 +1799,7 @@ libvirt_storage_backend_sheepdog_priv_la_CFLAGS =3D \ noinst_LTLIBRARIES +=3D libvirt_storage_backend_sheepdog_priv.la =20 storagebackend_LTLIBRARIES +=3D libvirt_storage_backend_sheepdog.la -libvirt_storage_backend_sheepdog_la_LDFLAGS =3D \ - -module -avoid-version $(AM_LDFLAGS) +libvirt_storage_backend_sheepdog_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) libvirt_storage_backend_sheepdog_la_LIBADD =3D libvirt.la ../gnulib/lib/li= bgnu.la endif WITH_STORAGE_SHEEPDOG =20 @@ -1821,8 +1813,7 @@ libvirt_storage_backend_gluster_la_CFLAGS =3D \ $(AM_CFLAGS) =20 storagebackend_LTLIBRARIES +=3D libvirt_storage_backend_gluster.la -libvirt_storage_backend_gluster_la_LDFLAGS =3D \ - -module -avoid-version $(AM_LDFLAGS) +libvirt_storage_backend_gluster_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) libvirt_storage_backend_gluster_la_LIBADD +=3D libvirt.la ../gnulib/lib/li= bgnu.la endif WITH_STORAGE_GLUSTER =20 @@ -1833,8 +1824,7 @@ libvirt_storage_backend_zfs_la_CFLAGS =3D \ $(AM_CFLAGS) =20 storagebackend_LTLIBRARIES +=3D libvirt_storage_backend_zfs.la -libvirt_storage_backend_zfs_la_LDFLAGS =3D \ - -module -avoid-version $(AM_LDFLAGS) +libvirt_storage_backend_zfs_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) libvirt_storage_backend_zfs_la_LIBADD =3D libvirt.la ../gnulib/lib/libgnu.= la endif WITH_STORAGE_ZFS =20 @@ -1846,8 +1836,7 @@ libvirt_storage_backend_vstorage_la_CFLAGS =3D \ $(AM_CFLAGS) =20 storagebackend_LTLIBRARIES +=3D libvirt_storage_backend_vstorage.la -libvirt_storage_backend_vstorage_la_LDFLAGS =3D \ - -module -avoid-version $(AM_LDFLAGS) +libvirt_storage_backend_vstorage_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) libvirt_storage_backend_vstorage_la_LIBADD =3D libvirt.la ../gnulib/lib/li= bgnu.la endif WITH_STORAGE_VSTORAGE =20 @@ -1860,7 +1849,7 @@ libvirt_driver_nodedev_la_CFLAGS =3D \ -I$(srcdir)/access \ -I$(srcdir)/conf \ $(AM_CFLAGS) $(LIBNL_CFLAGS) -libvirt_driver_nodedev_la_LDFLAGS =3D $(AM_LDFLAGS) +libvirt_driver_nodedev_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) libvirt_driver_nodedev_la_LIBADD =3D =20 if WITH_LIBVIRTD @@ -1877,7 +1866,6 @@ endif WITH_UDEV endif WITH_LIBVIRTD =20 libvirt_driver_nodedev_la_LIBADD +=3D libvirt.la ../gnulib/lib/libgnu.la -libvirt_driver_nodedev_la_LDFLAGS +=3D -module -avoid-version endif WITH_NODE_DEVICES =20 =20 @@ -1886,7 +1874,7 @@ noinst_LTLIBRARIES +=3D libvirt_driver_nwfilter_impl.= la libvirt_driver_nwfilter_la_SOURCES =3D libvirt_driver_nwfilter_la_LIBADD =3D libvirt_driver_nwfilter_impl.la mod_LTLIBRARIES +=3D libvirt_driver_nwfilter.la -libvirt_driver_nwfilter_la_LDFLAGS =3D -module -avoid-version $(AM_LDFLAGS) +libvirt_driver_nwfilter_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) libvirt_driver_nwfilter_impl_la_CFLAGS =3D \ $(LIBPCAP_CFLAGS) \ $(LIBNL_CFLAGS) \ @@ -1900,7 +1888,6 @@ libvirt_driver_nwfilter_impl_la_LIBADD =3D \ $(LIBNL_LIBS) \ $(DBUS_LIBS) libvirt_driver_nwfilter_impl_la_LIBADD +=3D libvirt.la ../gnulib/lib/libgn= u.la -libvirt_driver_nwfilter_impl_la_LDFLAGS +=3D -module -avoid-version libvirt_driver_nwfilter_impl_la_SOURCES =3D $(NWFILTER_DRIVER_SOURCES) endif WITH_NWFILTER =20 @@ -2576,7 +2563,7 @@ lockd_la_SOURCES =3D \ lockd_la_CFLAGS =3D -I$(srcdir)/conf \ $(XDR_CFLAGS) \ $(AM_CFLAGS) -lockd_la_LDFLAGS =3D -module -avoid-version $(AM_LDFLAGS) +lockd_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) lockd_la_LIBADD =3D libvirt.la ../gnulib/lib/libgnu.la augeas_DATA +=3D locking/libvirt_lockd.aug if WITH_DTRACE_PROBES @@ -2855,7 +2842,7 @@ if WITH_SANLOCK lockdriver_LTLIBRARIES +=3D sanlock.la sanlock_la_SOURCES =3D $(LOCK_DRIVER_SANLOCK_SOURCES) sanlock_la_CFLAGS =3D -I$(srcdir)/conf $(AM_CFLAGS) -sanlock_la_LDFLAGS =3D -module -avoid-version $(AM_LDFLAGS) +sanlock_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) sanlock_la_LIBADD =3D -lsanlock_client libvirt.la ../gnulib/lib/libgnu.la =20 augeas_DATA +=3D locking/libvirt_sanlock.aug --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 18:41:09 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1516873160710691.9449493910412; Thu, 25 Jan 2018 01:39:20 -0800 (PST) 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 A6F471279B; Thu, 25 Jan 2018 09:39:19 +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 6BC8F6064E; Thu, 25 Jan 2018 09:39:19 +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 33AE818033E0; Thu, 25 Jan 2018 09:39:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0P9dIpY003355 for ; Thu, 25 Jan 2018 04:39:18 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7372D50F4E; Thu, 25 Jan 2018 09:39:18 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 42ED46031B; Thu, 25 Jan 2018 09:39:16 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 25 Jan 2018 09:38:24 +0000 Message-Id: <20180125093825.5834-14-berrange@redhat.com> In-Reply-To: <20180125093825.5834-1-berrange@redhat.com> References: <20180125093825.5834-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 13/14] build: passing the "-z defs" linker flag to prevent undefined symbols 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 25 Jan 2018 09:39:20 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Undefined symbols are a bad thing in general because they can get resolved in unexpected ways at runtime if multiple sources provide the same symbol name. For example both glibc and libtirpc may provide XDR symbols and we want to ensure that we resolve to libtirpc if that's what we originally built against. The toolchain maintainers thus strongly recommend that all applications use the '-z defs' linker flag to prevent undefined symbols. This is shortly becoming part of the default linker flags for RPMs. As an added benefit this aligns Linux builds with Windows builds, where the linker has never permitted undefined symbols. Signed-off-by: Daniel P. Berrange --- configure.ac | 1 + daemon/Makefile.am | 3 +++ m4/virt-linker-no-undefined.m4 | 32 ++++++++++++++++++++++++++++++++ src/Makefile.am | 36 ++++++++++++++++++++---------------- tools/Makefile.am | 1 + 5 files changed, 57 insertions(+), 16 deletions(-) create mode 100644 m4/virt-linker-no-undefined.m4 diff --git a/configure.ac b/configure.ac index 4cccf7f4de..7997ec5a14 100644 --- a/configure.ac +++ b/configure.ac @@ -237,6 +237,7 @@ LIBVIRT_COMPILE_WARNINGS LIBVIRT_COMPILE_PIE LIBVIRT_LINKER_RELRO LIBVIRT_LINKER_NO_INDIRECT +LIBVIRT_LINKER_NO_UNDEFINED =20 LIBVIRT_ARG_APPARMOR LIBVIRT_ARG_ATTR diff --git a/daemon/Makefile.am b/daemon/Makefile.am index f7519efe2f..e20b551be9 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -133,6 +133,7 @@ libvirtd_conf_la_LDFLAGS =3D \ $(PIE_LDFLAGS) \ $(COVERAGE_LDFLAGS) \ $(NO_INDIRECT_LDFLAGS) \ + $(NO_UNDEFINED_LDFLAGS) \ $(NULL) libvirtd_conf_la_LIBADD =3D $(LIBXML_LIBS) =20 @@ -153,6 +154,7 @@ libvirtd_admin_la_LDFLAGS =3D \ $(RELRO_LDFLAGS) \ $(COVERAGE_LDFLAGS) \ $(NO_INDIRECT_LDFLAGS) \ + $(NO_UNDEFINED_LDFLAGS) \ $(NULL) libvirtd_admin_la_LIBADD =3D \ ../src/libvirt-admin.la @@ -187,6 +189,7 @@ libvirtd_LDFLAGS =3D \ $(PIE_LDFLAGS) \ $(COVERAGE_LDFLAGS) \ $(NO_INDIRECT_LDFLAGS) \ + $(NO_UNDEFINED_LDFLAGS) \ $(NULL) =20 libvirtd_LDADD =3D \ diff --git a/m4/virt-linker-no-undefined.m4 b/m4/virt-linker-no-undefined.m4 new file mode 100644 index 0000000000..532b0de212 --- /dev/null +++ b/m4/virt-linker-no-undefined.m4 @@ -0,0 +1,32 @@ +dnl +dnl Check for -z defs linker flag +dnl +dnl Copyright (C) 2013-2018 Red Hat, Inc. +dnl +dnl This library is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU Lesser General Public +dnl License as published by the Free Software Foundation; either +dnl version 2.1 of the License, or (at your option) any later version. +dnl +dnl This library is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl Lesser General Public License for more details. +dnl +dnl You should have received a copy of the GNU Lesser General Public +dnl License along with this library. If not, see +dnl . +dnl + +AC_DEFUN([LIBVIRT_LINKER_NO_UNDEFINED],[ + AC_MSG_CHECKING([for how to stop undefined symbols at link time]) + + NO_UNDEFINED_LDFLAGS=3D + ld_help=3D`$LD --help 2>&1` + case $ld_help in + *"-z defs"*) NO_UNDEFINED_LDFLAGS=3D"-Wl,-z -Wl,defs" ;; + esac + AC_SUBST([NO_UNDEFINED_LDFLAGS]) + + AC_MSG_RESULT([$NO_UNDEFINED_LDFLAGS]) +]) diff --git a/src/Makefile.am b/src/Makefile.am index 335b3a0c81..8fddafee51 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -52,6 +52,7 @@ AM_LDFLAGS =3D $(DRIVER_MODULES_LDFLAGS) \ $(MINGW_EXTRA_LDFLAGS) \ $(NULL) AM_LDFLAGS_MOD =3D -module -avoid-version $(AM_LDFLAGS) +AM_LDFLAGS_MOD_NOUNDEF =3D $(AM_LDFLAGS_MOD) $(NO_UNDEFINED_LDFLAGS) =20 POD2MAN =3D pod2man -c "Virtualization Support" -r "$(PACKAGE)-$(VERSION)" =20 @@ -1336,7 +1337,7 @@ libvirt_driver_xen_la_SOURCES =3D libvirt_driver_xen_la_LIBADD =3D libvirt_driver_xen_impl.la mod_LTLIBRARIES +=3D libvirt_driver_xen.la libvirt_driver_xen_la_LIBADD +=3D libvirt.la ../gnulib/lib/libgnu.la -libvirt_driver_xen_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) +libvirt_driver_xen_la_LDFLAGS =3D $(AM_LDFLAGS_MOD_NOUNDEF) =20 libvirt_driver_xen_impl_la_CFLAGS =3D \ $(XEN_CFLAGS) \ @@ -1382,7 +1383,7 @@ libvirt_driver_vbox_la_LIBADD =3D libvirt_driver_vbox= _impl.la mod_LTLIBRARIES +=3D \ libvirt_driver_vbox.la libvirt_driver_vbox_la_LIBADD +=3D libvirt.la ../gnulib/lib/libgnu.la -libvirt_driver_vbox_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) +libvirt_driver_vbox_la_LDFLAGS =3D $(AM_LDFLAGS_MOD_NOUNDEF) =20 libvirt_driver_vbox_impl_la_CFLAGS =3D \ -I$(srcdir)/conf \ @@ -1411,7 +1412,7 @@ libvirt_driver_libxl_la_SOURCES =3D libvirt_driver_libxl_la_LIBADD =3D libvirt_driver_libxl_impl.la mod_LTLIBRARIES +=3D libvirt_driver_libxl.la libvirt_driver_libxl_la_LIBADD +=3D libvirt.la ../gnulib/lib/libgnu.la -libvirt_driver_libxl_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) +libvirt_driver_libxl_la_LDFLAGS =3D $(AM_LDFLAGS_MOD_NOUNDEF) =20 libvirt_driver_libxl_impl_la_CFLAGS =3D \ $(LIBXL_CFLAGS) \ @@ -1440,7 +1441,7 @@ libvirt_driver_qemu_la_SOURCES =3D libvirt_driver_qemu_la_LIBADD =3D libvirt_driver_qemu_impl.la mod_LTLIBRARIES +=3D libvirt_driver_qemu.la libvirt_driver_qemu_la_LIBADD +=3D libvirt.la ../gnulib/lib/libgnu.la -libvirt_driver_qemu_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) +libvirt_driver_qemu_la_LDFLAGS =3D $(AM_LDFLAGS_MOD_NOUNDEF) =20 libvirt_driver_qemu_impl_la_CFLAGS =3D \ $(GNUTLS_CFLAGS) \ @@ -1475,7 +1476,7 @@ libvirt_driver_lxc_la_SOURCES =3D libvirt_driver_lxc_la_LIBADD =3D libvirt_driver_lxc_impl.la mod_LTLIBRARIES +=3D libvirt_driver_lxc.la libvirt_driver_lxc_la_LIBADD +=3D libvirt.la ../gnulib/lib/libgnu.la -libvirt_driver_lxc_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) +libvirt_driver_lxc_la_LDFLAGS =3D $(AM_LDFLAGS_MOD_NOUNDEF) =20 libvirt_driver_lxc_impl_la_CFLAGS =3D \ $(LIBNL_CFLAGS) \ @@ -1512,7 +1513,7 @@ libvirt_driver_uml_la_SOURCES =3D libvirt_driver_uml_la_LIBADD =3D libvirt_driver_uml_impl.la mod_LTLIBRARIES +=3D libvirt_driver_uml.la libvirt_driver_uml_la_LIBADD +=3D libvirt.la ../gnulib/lib/libgnu.la -libvirt_driver_uml_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) +libvirt_driver_uml_la_LDFLAGS =3D $(AM_LDFLAGS_MOD_NOUNDEF) =20 libvirt_driver_uml_impl_la_CFLAGS =3D \ -I$(srcdir)/access \ @@ -1584,7 +1585,7 @@ libvirt_driver_vz_la_SOURCES =3D libvirt_driver_vz_la_LIBADD =3D libvirt_driver_vz_impl.la mod_LTLIBRARIES +=3D libvirt_driver_vz.la libvirt_driver_vz_la_LIBADD +=3D libvirt.la ../gnulib/lib/libgnu.la -libvirt_driver_vz_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) +libvirt_driver_vz_la_LDFLAGS =3D $(AM_LDFLAGS_MOD_NOUNDEF) libvirt_driver_vz_impl_la_CFLAGS =3D \ -I$(srcdir)/conf \ -I$(srcdir)/access \ @@ -1600,7 +1601,7 @@ libvirt_driver_bhyve_la_SOURCES =3D libvirt_driver_bhyve_la_LIBADD =3D libvirt_driver_bhyve_impl.la mod_LTLIBRARIES +=3D libvirt_driver_bhyve.la libvirt_driver_bhyve_la_LIBADD +=3D libvirt.la ../gnulib/lib/libgnu.la -libvirt_driver_bhyve_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) +libvirt_driver_bhyve_la_LDFLAGS =3D $(AM_LDFLAGS_MOD_NOUNDEF) =20 libvirt_driver_bhyve_impl_la_CFLAGS =3D \ -I$(srcdir)/access \ @@ -1626,7 +1627,7 @@ libvirt_driver_network_la_LIBADD +=3D libvirt.la ../g= nulib/lib/libgnu.la \ $(LIBNL_LIBS) \ $(DBUS_LIBS) \ $(NULL) -libvirt_driver_network_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) +libvirt_driver_network_la_LDFLAGS =3D $(AM_LDFLAGS_MOD_NOUNDEF) =20 libvirt_driver_network_impl_la_CFLAGS =3D \ $(LIBNL_CFLAGS) \ @@ -1646,7 +1647,7 @@ libvirt_driver_interface_la_CFLAGS =3D \ -I$(srcdir)/access \ -I$(srcdir)/conf \ $(AM_CFLAGS) $(LIBNL_CFLAGS) -libvirt_driver_interface_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) +libvirt_driver_interface_la_LDFLAGS =3D $(AM_LDFLAGS_MOD_NOUNDEF) libvirt_driver_interface_la_LIBADD =3D if WITH_NETCF libvirt_driver_interface_la_CFLAGS +=3D $(NETCF_CFLAGS) @@ -1667,7 +1668,7 @@ libvirt_driver_secret_la_CFLAGS =3D \ -I$(srcdir)/conf \ $(AM_CFLAGS) libvirt_driver_secret_la_LIBADD =3D libvirt.la ../gnulib/lib/libgnu.la -libvirt_driver_secret_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) +libvirt_driver_secret_la_LDFLAGS =3D $(AM_LDFLAGS_MOD_NOUNDEF) libvirt_driver_secret_la_SOURCES =3D $(SECRET_DRIVER_SOURCES) endif WITH_SECRETS =20 @@ -1695,7 +1696,7 @@ libvirt_driver_storage_la_SOURCES =3D libvirt_driver_storage_la_LIBADD =3D libvirt_driver_storage_impl.la mod_LTLIBRARIES +=3D libvirt_driver_storage.la libvirt_driver_storage_la_LIBADD +=3D libvirt.la ../gnulib/lib/libgnu.la -libvirt_driver_storage_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) +libvirt_driver_storage_la_LDFLAGS =3D $(AM_LDFLAGS_MOD_NOUNDEF) libvirt_driver_storage_impl_la_SOURCES +=3D $(STORAGE_DRIVER_SOURCES) =20 =20 @@ -1849,7 +1850,7 @@ libvirt_driver_nodedev_la_CFLAGS =3D \ -I$(srcdir)/access \ -I$(srcdir)/conf \ $(AM_CFLAGS) $(LIBNL_CFLAGS) -libvirt_driver_nodedev_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) +libvirt_driver_nodedev_la_LDFLAGS =3D $(AM_LDFLAGS_MOD_NOUNDEF) libvirt_driver_nodedev_la_LIBADD =3D =20 if WITH_LIBVIRTD @@ -1874,7 +1875,7 @@ noinst_LTLIBRARIES +=3D libvirt_driver_nwfilter_impl.= la libvirt_driver_nwfilter_la_SOURCES =3D libvirt_driver_nwfilter_la_LIBADD =3D libvirt_driver_nwfilter_impl.la mod_LTLIBRARIES +=3D libvirt_driver_nwfilter.la -libvirt_driver_nwfilter_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) +libvirt_driver_nwfilter_la_LDFLAGS =3D $(AM_LDFLAGS_MOD_NOUNDEF) libvirt_driver_nwfilter_impl_la_CFLAGS =3D \ $(LIBPCAP_CFLAGS) \ $(LIBNL_CFLAGS) \ @@ -2361,6 +2362,7 @@ libvirt_la_LDFLAGS =3D \ $(VERSION_SCRIPT_FLAGS)$(LIBVIRT_SYMBOL_FILE) \ -version-info $(LIBVIRT_VERSION_INFO) \ $(LIBVIRT_NODELETE) \ + $(NO_UNDEFINED_LDFLAGS) \ $(AM_LDFLAGS) \ $(NULL) libvirt_la_BUILT_LIBADD +=3D ../gnulib/lib/libgnu.la @@ -2563,7 +2565,7 @@ lockd_la_SOURCES =3D \ lockd_la_CFLAGS =3D -I$(srcdir)/conf \ $(XDR_CFLAGS) \ $(AM_CFLAGS) -lockd_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) +lockd_la_LDFLAGS =3D $(AM_LDFLAGS_MOD_NOUNDEF) lockd_la_LIBADD =3D libvirt.la ../gnulib/lib/libgnu.la augeas_DATA +=3D locking/libvirt_lockd.aug if WITH_DTRACE_PROBES @@ -2603,6 +2605,7 @@ virtlockd_CFLAGS =3D \ virtlockd_LDFLAGS =3D \ $(AM_LDFLAGS) \ $(PIE_LDFLAGS) \ + $(NO_UNDEFINED_LDFLAGS) \ $(NULL) virtlockd_LDADD =3D \ libvirt-net-rpc-server.la \ @@ -2629,6 +2632,7 @@ virtlogd_CFLAGS =3D \ virtlogd_LDFLAGS =3D \ $(AM_LDFLAGS) \ $(PIE_LDFLAGS) \ + $(NO_UNDEFINED_LDFLAGS) \ $(NULL) virtlogd_LDADD =3D \ libvirt-net-rpc-server.la \ @@ -2842,7 +2846,7 @@ if WITH_SANLOCK lockdriver_LTLIBRARIES +=3D sanlock.la sanlock_la_SOURCES =3D $(LOCK_DRIVER_SANLOCK_SOURCES) sanlock_la_CFLAGS =3D -I$(srcdir)/conf $(AM_CFLAGS) -sanlock_la_LDFLAGS =3D $(AM_LDFLAGS_MOD) +sanlock_la_LDFLAGS =3D $(AM_LDFLAGS_MOD_NOUNDEF) sanlock_la_LIBADD =3D -lsanlock_client libvirt.la ../gnulib/lib/libgnu.la =20 augeas_DATA +=3D locking/libvirt_sanlock.aug diff --git a/tools/Makefile.am b/tools/Makefile.am index e9597cdb47..627e06addc 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -35,6 +35,7 @@ AM_CFLAGS =3D \ AM_LDFLAGS =3D \ $(RELRO_LDFLAGS) \ $(NO_INDIRECT_LDFLAGS) \ + $(NO_UNDEFINED_LDFLAGS) \ $(NULL) =20 ICON_FILES =3D \ --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 18:41:09 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 151687316415264.57102091478669; Thu, 25 Jan 2018 01:39:24 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0CAD82CE91D; Thu, 25 Jan 2018 09:39:23 +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 CD01718020; Thu, 25 Jan 2018 09:39:22 +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 8CC8318033E7; Thu, 25 Jan 2018 09:39:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0P9dLR0003372 for ; Thu, 25 Jan 2018 04:39:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id 48046605DC; Thu, 25 Jan 2018 09:39:21 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9FA3450F58; Thu, 25 Jan 2018 09:39:18 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 25 Jan 2018 09:38:25 +0000 Message-Id: <20180125093825.5834-15-berrange@redhat.com> In-Reply-To: <20180125093825.5834-1-berrange@redhat.com> References: <20180125093825.5834-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 14/14] build: link libvirt_lxc against libvirt.so 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 25 Jan 2018 09:39:23 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Rather than static linking in various of the helper libraries to libvirt_lxc, just link against the main libvirt.so. This is more memory and time efficient because it will already be cached in memory and sharable between processes. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/Makefile.am | 6 +----- src/libvirt_private.syms | 2 ++ 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 8fddafee51..1dc518fab9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -3084,11 +3084,7 @@ libvirt_lxc_LDFLAGS =3D \ $(NULL) libvirt_lxc_LDADD =3D \ $(FUSE_LIBS) \ - libvirt-net-rpc-server.la \ - libvirt-net-rpc.la \ - libvirt_security_manager.la \ - libvirt_conf.la \ - libvirt_util.la \ + libvirt.la \ ../gnulib/lib/libgnu.la if WITH_DTRACE_PROBES libvirt_lxc_LDADD +=3D libvirt_probes.lo diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 7ebd0f6066..a22bc80b06 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -347,6 +347,7 @@ virDomainDiskSetType; virDomainDiskTranslateSourcePool; virDomainFSDefFree; virDomainFSDefNew; +virDomainFSDriverTypeToString; virDomainFSIndexByName; virDomainFSInsert; virDomainFSRemove; @@ -476,6 +477,7 @@ virDomainObjGetOneDefState; virDomainObjGetPersistentDef; virDomainObjGetState; virDomainObjNew; +virDomainObjParseFile; virDomainObjParseNode; virDomainObjRemoveTransientDef; virDomainObjSetDefTransient; --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list