[libvirt] [PATCH] util: fix handling of unspecified port in URI
by Daniel P. Berrangé
When no server name is provided in the URI, modern versions of libxml2
will set the port to '-1'. This is a change from behaviour with earlier
versions which set it to 0.
Libvirt expects the port to be 0 in these cases and as a result we get a
bug when connecting to URIs which lack a server name:
$ virsh -c test+ssh:///default list
error: failed to connect to the hypervisor
error: Cannot recv data: Bad port '-1': Connection reset by peer
This libxml2 change was attempting to fix another bug identified by
libvirt where it didn't roundtrip URIs correctly in:
https://github.com/GNOME/libxml2/commit/beb7281055dbf0ed4d041022a67c6c5cf...
Essentially libxml2 was not expecting apps to look at the URI port
field when the server name is not provided. This was a reasonable
assumption, but none the less libvirt did look at it :-)
The fix is to ensure we explicitly set port to 0 when server name
is not present, avoiding undefined behaviour for the port field in
libxml2.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/util/viruri.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/util/viruri.c b/src/util/viruri.c
index d4b793f439..c8811f64c6 100644
--- a/src/util/viruri.c
+++ b/src/util/viruri.c
@@ -171,7 +171,16 @@ virURIParse(const char *uri)
goto error;
if (VIR_STRDUP(ret->server, xmluri->server) < 0)
goto error;
- ret->port = xmluri->port;
+ /* xmluri->port value is not defined if server was
+ * not given. Modern versions libxml2 fill port
+ * differently to old versions in this case, so
+ * don't rely on it. eg libxml2 git commit:
+ * beb7281055dbf0ed4d041022a67c6c5cfd126f25
+ */
+ if (!ret->server || STREQ(ret->server, ""))
+ ret->port = 0;
+ else
+ ret->port = xmluri->port;
if (VIR_STRDUP(ret->path, xmluri->path) < 0)
goto error;
#ifdef HAVE_XMLURI_QUERY_RAW
--
2.19.1
5 years, 11 months
[libvirt] [PATCH 0/2] Don't perform the vfio-ap mdev validation in post parse
by Erik Skultety
Move the respective bits to QEMU validation code instead.
Erik Skultety (2):
qemu: Extract MDEV VFIO PCI validation code into a separate helper
conf: Move VFIO AP validation from post parse to QEMU validation code
src/conf/domain_conf.c | 28 -------------------
src/qemu/qemu_domain.c | 61 +++++++++++++++++++++++++++++++++++++-----
2 files changed, 55 insertions(+), 34 deletions(-)
--
2.19.1
5 years, 11 months
[libvirt] [PATCH v3] lxc: Include support to lxc version 3.0 or higher.
by Julio Faracco
This patch introduce the new settings for LXC 3.0 or higher. The older
versions keep the compatibility to deprecated settings for LXC, but
after release 3.0, the compatibility was removed. This commit adds the
support to the refactored settings.
v1-v2: Michal's suggestions to handle differences between versions.
v2-v3: Adding suggestions from Pino and John too.
Signed-off-by: Julio Faracco <jcfaracco(a)gmail.com>
---
src/lxc/lxc_native.c | 45 +++++++++++++++++++++++++++++++-------------
1 file changed, 32 insertions(+), 13 deletions(-)
diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c
index cbdec723dd..d3ba12bb0e 100644
--- a/src/lxc/lxc_native.c
+++ b/src/lxc/lxc_native.c
@@ -200,8 +200,13 @@ lxcSetRootfs(virDomainDefPtr def,
int type = VIR_DOMAIN_FS_TYPE_MOUNT;
VIR_AUTOFREE(char *) value = NULL;
- if (virConfGetValueString(properties, "lxc.rootfs", &value) <= 0)
- return -1;
+ if (virConfGetValueString(properties, "lxc.rootfs.path", &value) <= 0) {
+ virResetLastError();
+
+ /* Check for pre LXC 3.0 legacy key */
+ if (virConfGetValueString(properties, "lxc.rootfs", &value) <= 0)
+ return -1;
+ }
if (STRPREFIX(value, "/dev/"))
type = VIR_DOMAIN_FS_TYPE_BLOCK;
@@ -684,8 +689,13 @@ lxcCreateConsoles(virDomainDefPtr def, virConfPtr properties)
virDomainChrDefPtr console;
size_t i;
- if (virConfGetValueString(properties, "lxc.tty", &value) <= 0)
- return 0;
+ if (virConfGetValueString(properties, "lxc.tty.max", &value) <= 0) {
+ virResetLastError();
+
+ /* Check for pre LXC 3.0 legacy key */
+ if (virConfGetValueString(properties, "lxc.tty", &value) <= 0)
+ return 0;
+ }
if (virStrToLong_i(value, NULL, 10, &nbttys) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to parse int: '%s'"),
@@ -724,12 +734,13 @@ lxcIdmapWalkCallback(const char *name, virConfValuePtr value, void *data)
char type;
unsigned long start, target, count;
- if (STRNEQ(name, "lxc.id_map") || !value->str)
+ /* LXC 3.0 uses "lxc.idmap", while legacy used "lxc.id_map" */
+ if (STRNEQ(name, "lxc.idmap") || STRNEQ(name, "lxc.id_map") || !value->str)
return 0;
if (sscanf(value->str, "%c %lu %lu %lu", &type,
&target, &start, &count) != 4) {
- virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid lxc.id_map: '%s'"),
+ virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid: '%s'"),
value->str);
return -1;
}
@@ -1041,19 +1052,27 @@ lxcParseConfigString(const char *config,
if (VIR_STRDUP(vmdef->os.init, "/sbin/init") < 0)
goto error;
- if (virConfGetValueString(properties, "lxc.utsname", &value) <= 0 ||
- VIR_STRDUP(vmdef->name, value) < 0)
- goto error;
+ if (virConfGetValueString(properties, "lxc.uts.name", &value) <= 0) {
+ virResetLastError();
+
+ /* Check for pre LXC 3.0 legacy key */
+ if (virConfGetValueString(properties, "lxc.utsname", &value) <= 0)
+ goto error;
+ }
+
if (!vmdef->name && (VIR_STRDUP(vmdef->name, "unnamed") < 0))
goto error;
if (lxcSetRootfs(vmdef, properties) < 0)
goto error;
- /* Look for fstab: we shouldn't have it */
- if (virConfGetValue(properties, "lxc.mount")) {
+ /* LXC 3.0 uses "lxc.mount.fstab", while legacy used just "lxc.mount".
+ * In either case, generate the error to use "lxc.mount.entry" instead */
+ if (virConfGetValue(properties, "lxc.mount.fstab") ||
+ virConfGetValue(properties, "lxc.mount")) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
- _("lxc.mount found, use lxc.mount.entry lines instead"));
+ _("lxc.mount.fstab or lxc.mount found, use "
+ "lxc.mount.entry lines instead"));
goto error;
}
@@ -1069,7 +1088,7 @@ lxcParseConfigString(const char *config,
if (lxcCreateConsoles(vmdef, properties) < 0)
goto error;
- /* lxc.id_map */
+ /* lxc.idmap or legacy lxc.id_map */
if (virConfWalk(properties, lxcIdmapWalkCallback, vmdef) < 0)
goto error;
--
2.19.1
5 years, 11 months
[libvirt] [PULL 0/4] Fixes 31 20181112 patches
by Gerd Hoffmann
The following changes since commit 460f0236c12a86a38692c12d9bf8e2391dc10a77:
Merge remote-tracking branch 'remotes/thibault/tags/samuel-thibault' into staging (2018-11-12 10:12:07 +0000)
are available in the git repository at:
git://git.kraxel.org/qemu tags/fixes-31-20181112-pull-request
for you to fetch changes up to f1aba960cc40ab65fa88c8678883bd2201708c55:
ui/gtk: fix cursor in egl mode (2018-11-12 14:15:54 +0100)
----------------------------------------------------------------
fixes for 3.1: mark bt as deprecated, bugfixes for pulse, gtk and edid.
----------------------------------------------------------------
Gerd Hoffmann (2):
pulseaudio: process audio data in smaller chunks
ui/gtk: fix cursor in egl mode
Marc-André Lureau (1):
edid: silence a stringop-overflow warning
Thomas Huth (1):
bt: Mark the bluetooth subsystem as deprecated
audio/paaudio.c | 4 ++--
hw/display/edid-generate.c | 2 +-
ui/gtk-egl.c | 17 ++++++++++++-----
vl.c | 4 ++++
qemu-deprecated.texi | 7 +++++++
qemu-options.hx | 4 ++++
6 files changed, 30 insertions(+), 8 deletions(-)
--
2.9.3
5 years, 11 months
[libvirt] [PATCH v2] conf: Add new module node_device_util
by Erik Skultety
There's a lot of stuff going on in src/conf/nodedev_conf which is
sometimes not directly related to config and we're not really consistent
with putting only parser/formatter related stuff here, e.g. like we do
for domains. So, let's start simply by adding a new module
node_device_util containing some of the helpers. Unfortunately, even
though these helpers tend to open a secondary driver connection and would
be much therefore better suited as a nodedev driver module, we can't do
that without pulling headers from the driver into conf/ and that's wrong
because we want conf/ to stay driver-agnostic.
Signed-off-by: Erik Skultety <eskultet(a)redhat.com>
---
src/conf/Makefile.inc.am | 2 +
src/conf/node_device_conf.c | 199 -----------------------
src/conf/node_device_conf.h | 11 --
src/conf/node_device_util.c | 229 +++++++++++++++++++++++++++
src/conf/node_device_util.h | 35 ++++
src/conf/virstorageobj.c | 1 +
src/libvirt_private.syms | 7 +-
src/node_device/node_device_driver.c | 1 +
src/storage/storage_backend_scsi.c | 1 +
9 files changed, 273 insertions(+), 213 deletions(-)
create mode 100644 src/conf/node_device_util.c
create mode 100644 src/conf/node_device_util.h
diff --git a/src/conf/Makefile.inc.am b/src/conf/Makefile.inc.am
index af23810640..219ff350d7 100644
--- a/src/conf/Makefile.inc.am
+++ b/src/conf/Makefile.inc.am
@@ -119,6 +119,8 @@ SECRET_CONF_SOURCES = \
NODE_DEVICE_CONF_SOURCES = \
conf/node_device_conf.c \
conf/node_device_conf.h \
+ conf/node_device_util.c \
+ conf/node_device_util.h \
conf/virnodedeviceobj.c \
conf/virnodedeviceobj.h \
$(NULL)
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index 03bd794dc0..74a7bc3933 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -2220,205 +2220,6 @@ virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps)
}
-/* virNodeDeviceGetParentName
- * @conn: Connection pointer
- * @nodedev_name: Node device to lookup
- *
- * Lookup the node device by name and return the parent name
- *
- * Returns parent name on success, caller is responsible for freeing;
- * otherwise, returns NULL on failure
- */
-char *
-virNodeDeviceGetParentName(virConnectPtr conn,
- const char *nodedev_name)
-{
- virNodeDevicePtr device = NULL;
- char *parent;
-
- if (!(device = virNodeDeviceLookupByName(conn, nodedev_name))) {
- virReportError(VIR_ERR_XML_ERROR,
- _("Cannot find '%s' in node device database"),
- nodedev_name);
- return NULL;
- }
-
- ignore_value(VIR_STRDUP(parent, virNodeDeviceGetParent(device)));
- virObjectUnref(device);
-
- return parent;
-}
-
-
-/**
- * @fchost: Pointer to vHBA adapter
- *
- * Create a vHBA for Storage. This code accomplishes this via searching
- * through the sysfs for scsi_host/fc_host in order to first ensure some
- * vHBA doesn't already exist for the requested wwnn/wwpn (e.g. an unmanaged
- * vHBA) and to search for the parent vport capable scsi_host by name,
- * wwnn/wwpn, or fabric_wwn (if provided). If no parent is provided, then
- * a vport capable scsi_host will be selected.
- *
- * Returns vHBA name on success, NULL on failure with an error message set
- */
-char *
-virNodeDeviceCreateVport(virStorageAdapterFCHostPtr fchost)
-{
- unsigned int parent_host;
- char *name = NULL;
- char *parent_hoststr = NULL;
- bool skip_capable_check = false;
-
- VIR_DEBUG("parent='%s', wwnn='%s' wwpn='%s'",
- NULLSTR(fchost->parent), fchost->wwnn, fchost->wwpn);
-
- if (fchost->parent) {
- if (VIR_STRDUP(parent_hoststr, fchost->parent) < 0)
- goto cleanup;
- } else if (fchost->parent_wwnn && fchost->parent_wwpn) {
- if (!(parent_hoststr = virVHBAGetHostByWWN(NULL, fchost->parent_wwnn,
- fchost->parent_wwpn))) {
- virReportError(VIR_ERR_XML_ERROR, "%s",
- _("cannot find parent using provided wwnn/wwpn"));
- goto cleanup;
- }
- } else if (fchost->parent_fabric_wwn) {
- if (!(parent_hoststr =
- virVHBAGetHostByFabricWWN(NULL, fchost->parent_fabric_wwn))) {
- virReportError(VIR_ERR_XML_ERROR, "%s",
- _("cannot find parent using provided fabric_wwn"));
- goto cleanup;
- }
- } else {
- if (!(parent_hoststr = virVHBAFindVportHost(NULL))) {
- virReportError(VIR_ERR_XML_ERROR, "%s",
- _("'parent' for vHBA not specified, and "
- "cannot find one on this host"));
- goto cleanup;
- }
- skip_capable_check = true;
- }
-
- if (virSCSIHostGetNumber(parent_hoststr, &parent_host) < 0)
- goto cleanup;
-
- /* NOTE:
- * We do not save the parent_hoststr in fchost->parent since
- * we could be writing out the 'def' to the saved XML config.
- * If we wrote out the name in the XML, then future starts would
- * always use the same parent rather than finding the "best available"
- * parent. Besides we have a way to determine the parent based on
- * the 'name' field.
- */
- if (!skip_capable_check && !virVHBAPathExists(NULL, parent_host)) {
- virReportError(VIR_ERR_XML_ERROR,
- _("parent '%s' specified for vHBA does not exist"),
- parent_hoststr);
- goto cleanup;
- }
-
- if (virVHBAManageVport(parent_host, fchost->wwpn, fchost->wwnn,
- VPORT_CREATE) < 0)
- goto cleanup;
-
- /* Let's ensure the device was created */
- virWaitForDevices();
- if (!(name = virVHBAGetHostByWWN(NULL, fchost->wwnn, fchost->wwpn))) {
- ignore_value(virVHBAManageVport(parent_host, fchost->wwpn, fchost->wwnn,
- VPORT_DELETE));
- goto cleanup;
- }
-
- cleanup:
- VIR_FREE(parent_hoststr);
- return name;
-}
-
-
-/**
- * @conn: Connection pointer
- * @fchost: Pointer to vHBA adapter
- *
- * As long as the vHBA is being managed, search for the scsi_host via the
- * provided wwnn/wwpn and then find the corresponding parent scsi_host in
- * order to send the delete request.
- *
- * Returns 0 on success, -1 on failure
- */
-int
-virNodeDeviceDeleteVport(virConnectPtr conn,
- virStorageAdapterFCHostPtr fchost)
-{
- char *name = NULL;
- char *scsi_host_name = NULL;
- unsigned int parent_host;
- char *vhba_parent = NULL;
- int ret = -1;
-
- VIR_DEBUG("conn=%p parent='%s', managed='%d' wwnn='%s' wwpn='%s'",
- conn, NULLSTR(fchost->parent), fchost->managed,
- fchost->wwnn, fchost->wwpn);
-
- /* If we're not managing the deletion of the vHBA, then just return */
- if (fchost->managed != VIR_TRISTATE_BOOL_YES)
- return 0;
-
- /* Find our vHBA by searching the fc_host sysfs tree for our wwnn/wwpn */
- if (!(name = virVHBAGetHostByWWN(NULL, fchost->wwnn, fchost->wwpn))) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Failed to find fc_host for wwnn='%s' and wwpn='%s'"),
- fchost->wwnn, fchost->wwpn);
- goto cleanup;
- }
-
- if (virAsprintf(&scsi_host_name, "scsi_%s", name) < 0)
- goto cleanup;
-
- /* If at startup time we provided a parent, then use that to
- * get the parent_host value; otherwise, we have to determine
- * the parent scsi_host which we did not save at startup time
- */
- if (fchost->parent) {
- /* Someone provided a parent string at startup time that
- * was the same as the scsi_host - meaning we have a pool
- * backed to an HBA, so there won't be a vHBA to delete */
- if (STREQ(scsi_host_name, fchost->parent)) {
- ret = 0;
- goto cleanup;
- }
-
- if (virSCSIHostGetNumber(fchost->parent, &parent_host) < 0)
- goto cleanup;
- } else {
- if (!(vhba_parent = virNodeDeviceGetParentName(conn, scsi_host_name)))
- goto cleanup;
-
- /* If the parent is not a scsi_host, then this is a pool backed
- * directly to an HBA and there's no vHBA to remove - so we're done */
- if (!STRPREFIX(vhba_parent, "scsi_host")) {
- ret = 0;
- goto cleanup;
- }
-
- if (virSCSIHostGetNumber(vhba_parent, &parent_host) < 0)
- goto cleanup;
- }
-
- if (virVHBAManageVport(parent_host, fchost->wwpn, fchost->wwnn,
- VPORT_DELETE) < 0)
- goto cleanup;
-
- ret = 0;
-
- cleanup:
- VIR_FREE(name);
- VIR_FREE(vhba_parent);
- VIR_FREE(scsi_host_name);
- return ret;
-}
-
-
int
virNodeDeviceUpdateCaps(virNodeDeviceDefPtr def)
{
diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h
index 685ae30347..fde239183d 100644
--- a/src/conf/node_device_conf.h
+++ b/src/conf/node_device_conf.h
@@ -367,17 +367,6 @@ virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps);
VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV | \
VIR_CONNECT_LIST_NODE_DEVICES_CAP_CCW_DEV)
-char *
-virNodeDeviceGetParentName(virConnectPtr conn,
- const char *nodedev_name);
-
-char *
-virNodeDeviceCreateVport(virStorageAdapterFCHostPtr fchost);
-
-int
-virNodeDeviceDeleteVport(virConnectPtr conn,
- virStorageAdapterFCHostPtr fchost);
-
int
virNodeDeviceGetSCSIHostCaps(virNodeDevCapSCSIHostPtr scsi_host);
diff --git a/src/conf/node_device_util.c b/src/conf/node_device_util.c
new file mode 100644
index 0000000000..d1d9c3ee49
--- /dev/null
+++ b/src/conf/node_device_util.c
@@ -0,0 +1,229 @@
+/*
+ * node_device_util.c: helper functions for the node device driver
+ *
+ * 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
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+
+#include "internal.h"
+
+#include "node_device_util.h"
+#include "virlog.h"
+#include "virscsihost.h"
+#include "virstring.h"
+#include "virvhba.h"
+
+#define VIR_FROM_THIS VIR_FROM_NODEDEV
+
+VIR_LOG_INIT("node_device.node_device_util");
+
+/* virNodeDeviceGetParentName
+ * @conn: Connection pointer
+ * @nodedev_name: Node device to lookup
+ *
+ * Lookup the node device by name and return the parent name
+ *
+ * Returns parent name on success, caller is responsible for freeing;
+ * otherwise, returns NULL on failure
+ */
+char *
+virNodeDeviceGetParentName(virConnectPtr conn,
+ const char *nodedev_name)
+{
+ virNodeDevicePtr device = NULL;
+ char *parent;
+
+ if (!(device = virNodeDeviceLookupByName(conn, nodedev_name))) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("Cannot find '%s' in node device database"),
+ nodedev_name);
+ return NULL;
+ }
+
+ ignore_value(VIR_STRDUP(parent, virNodeDeviceGetParent(device)));
+ virObjectUnref(device);
+
+ return parent;
+}
+
+
+/**
+ * @fchost: Pointer to vHBA adapter
+ *
+ * Create a vHBA for Storage. This code accomplishes this via searching
+ * through the sysfs for scsi_host/fc_host in order to first ensure some
+ * vHBA doesn't already exist for the requested wwnn/wwpn (e.g. an unmanaged
+ * vHBA) and to search for the parent vport capable scsi_host by name,
+ * wwnn/wwpn, or fabric_wwn (if provided). If no parent is provided, then
+ * a vport capable scsi_host will be selected.
+ *
+ * Returns vHBA name on success, NULL on failure with an error message set
+ */
+char *
+virNodeDeviceCreateVport(virStorageAdapterFCHostPtr fchost)
+{
+ unsigned int parent_host;
+ char *name = NULL;
+ char *parent_hoststr = NULL;
+ bool skip_capable_check = false;
+
+ VIR_DEBUG("parent='%s', wwnn='%s' wwpn='%s'",
+ NULLSTR(fchost->parent), fchost->wwnn, fchost->wwpn);
+
+ if (fchost->parent) {
+ if (VIR_STRDUP(parent_hoststr, fchost->parent) < 0)
+ goto cleanup;
+ } else if (fchost->parent_wwnn && fchost->parent_wwpn) {
+ if (!(parent_hoststr = virVHBAGetHostByWWN(NULL, fchost->parent_wwnn,
+ fchost->parent_wwpn))) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("cannot find parent using provided wwnn/wwpn"));
+ goto cleanup;
+ }
+ } else if (fchost->parent_fabric_wwn) {
+ if (!(parent_hoststr =
+ virVHBAGetHostByFabricWWN(NULL, fchost->parent_fabric_wwn))) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("cannot find parent using provided fabric_wwn"));
+ goto cleanup;
+ }
+ } else {
+ if (!(parent_hoststr = virVHBAFindVportHost(NULL))) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("'parent' for vHBA not specified, and "
+ "cannot find one on this host"));
+ goto cleanup;
+ }
+ skip_capable_check = true;
+ }
+
+ if (virSCSIHostGetNumber(parent_hoststr, &parent_host) < 0)
+ goto cleanup;
+
+ /* NOTE:
+ * We do not save the parent_hoststr in fchost->parent since
+ * we could be writing out the 'def' to the saved XML config.
+ * If we wrote out the name in the XML, then future starts would
+ * always use the same parent rather than finding the "best available"
+ * parent. Besides we have a way to determine the parent based on
+ * the 'name' field.
+ */
+ if (!skip_capable_check && !virVHBAPathExists(NULL, parent_host)) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("parent '%s' specified for vHBA does not exist"),
+ parent_hoststr);
+ goto cleanup;
+ }
+
+ if (virVHBAManageVport(parent_host, fchost->wwpn, fchost->wwnn,
+ VPORT_CREATE) < 0)
+ goto cleanup;
+
+ /* Let's ensure the device was created */
+ virWaitForDevices();
+ if (!(name = virVHBAGetHostByWWN(NULL, fchost->wwnn, fchost->wwpn))) {
+ ignore_value(virVHBAManageVport(parent_host, fchost->wwpn, fchost->wwnn,
+ VPORT_DELETE));
+ goto cleanup;
+ }
+
+ cleanup:
+ VIR_FREE(parent_hoststr);
+ return name;
+}
+
+
+/**
+ * @conn: Connection pointer
+ * @fchost: Pointer to vHBA adapter
+ *
+ * As long as the vHBA is being managed, search for the scsi_host via the
+ * provided wwnn/wwpn and then find the corresponding parent scsi_host in
+ * order to send the delete request.
+ *
+ * Returns 0 on success, -1 on failure
+ */
+int
+virNodeDeviceDeleteVport(virConnectPtr conn,
+ virStorageAdapterFCHostPtr fchost)
+{
+ char *name = NULL;
+ char *scsi_host_name = NULL;
+ unsigned int parent_host;
+ char *vhba_parent = NULL;
+ int ret = -1;
+
+ VIR_DEBUG("conn=%p parent='%s', managed='%d' wwnn='%s' wwpn='%s'",
+ conn, NULLSTR(fchost->parent), fchost->managed,
+ fchost->wwnn, fchost->wwpn);
+
+ /* If we're not managing the deletion of the vHBA, then just return */
+ if (fchost->managed != VIR_TRISTATE_BOOL_YES)
+ return 0;
+
+ /* Find our vHBA by searching the fc_host sysfs tree for our wwnn/wwpn */
+ if (!(name = virVHBAGetHostByWWN(NULL, fchost->wwnn, fchost->wwpn))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to find fc_host for wwnn='%s' and wwpn='%s'"),
+ fchost->wwnn, fchost->wwpn);
+ goto cleanup;
+ }
+
+ if (virAsprintf(&scsi_host_name, "scsi_%s", name) < 0)
+ goto cleanup;
+
+ /* If at startup time we provided a parent, then use that to
+ * get the parent_host value; otherwise, we have to determine
+ * the parent scsi_host which we did not save at startup time
+ */
+ if (fchost->parent) {
+ /* Someone provided a parent string at startup time that
+ * was the same as the scsi_host - meaning we have a pool
+ * backed to an HBA, so there won't be a vHBA to delete */
+ if (STREQ(scsi_host_name, fchost->parent)) {
+ ret = 0;
+ goto cleanup;
+ }
+
+ if (virSCSIHostGetNumber(fchost->parent, &parent_host) < 0)
+ goto cleanup;
+ } else {
+ if (!(vhba_parent = virNodeDeviceGetParentName(conn, scsi_host_name)))
+ goto cleanup;
+
+ /* If the parent is not a scsi_host, then this is a pool backed
+ * directly to an HBA and there's no vHBA to remove - so we're done */
+ if (!STRPREFIX(vhba_parent, "scsi_host")) {
+ ret = 0;
+ goto cleanup;
+ }
+
+ if (virSCSIHostGetNumber(vhba_parent, &parent_host) < 0)
+ goto cleanup;
+ }
+
+ if (virVHBAManageVport(parent_host, fchost->wwpn, fchost->wwnn,
+ VPORT_DELETE) < 0)
+ goto cleanup;
+
+ ret = 0;
+
+ cleanup:
+ VIR_FREE(name);
+ VIR_FREE(vhba_parent);
+ VIR_FREE(scsi_host_name);
+ return ret;
+}
diff --git a/src/conf/node_device_util.h b/src/conf/node_device_util.h
new file mode 100644
index 0000000000..5cb225d03e
--- /dev/null
+++ b/src/conf/node_device_util.h
@@ -0,0 +1,35 @@
+/*
+ * node_device_util.h: utility functions for node device driver
+ *
+ * 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
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __VIR_NODE_DEVICE_UTIL_H__
+# define __VIR_NODE_DEVICE_UTIL_H__
+
+# include "conf/storage_adapter_conf.h"
+
+char *
+virNodeDeviceGetParentName(virConnectPtr conn,
+ const char *nodedev_name);
+
+char *
+virNodeDeviceCreateVport(virStorageAdapterFCHostPtr fchost);
+
+int
+virNodeDeviceDeleteVport(virConnectPtr conn,
+ virStorageAdapterFCHostPtr fchost);
+
+#endif /* __VIR_NODE_DEVICE_UTIL_H__ */
diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c
index 0b3ba84af2..30aabb2b37 100644
--- a/src/conf/virstorageobj.c
+++ b/src/conf/virstorageobj.c
@@ -22,6 +22,7 @@
#include "datatypes.h"
#include "node_device_conf.h"
+#include "node_device_util.h"
#include "virstorageobj.h"
#include "viralloc.h"
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 335210c31d..2343a757c1 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -722,14 +722,11 @@ virNodeDevCapsDefFree;
virNodeDevCapTypeFromString;
virNodeDevCapTypeToString;
virNodeDeviceCapsListExport;
-virNodeDeviceCreateVport;
virNodeDeviceDefFormat;
virNodeDeviceDefFree;
virNodeDeviceDefParseFile;
virNodeDeviceDefParseNode;
virNodeDeviceDefParseString;
-virNodeDeviceDeleteVport;
-virNodeDeviceGetParentName;
virNodeDeviceGetPCIDynamicCaps;
virNodeDeviceGetSCSIHostCaps;
virNodeDeviceGetSCSITargetCaps;
@@ -742,6 +739,10 @@ virNodeDeviceEventLifecycleNew;
virNodeDeviceEventStateRegisterID;
virNodeDeviceEventUpdateNew;
+# conf/node_device_util.h
+virNodeDeviceCreateVport;
+virNodeDeviceDeleteVport;
+virNodeDeviceGetParentName;
# conf/numa_conf.h
virDomainMemoryAccessTypeFromString;
diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index c46d0fbe12..0bcb3de053 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -37,6 +37,7 @@
#include "node_device_event.h"
#include "node_device_driver.h"
#include "node_device_hal.h"
+#include "node_device_util.h"
#include "virvhba.h"
#include "viraccessapicheck.h"
#include "virnetdev.h"
diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c
index 7c927c4d95..fe3a1e36ac 100644
--- a/src/storage/storage_backend_scsi.c
+++ b/src/storage/storage_backend_scsi.c
@@ -35,6 +35,7 @@
#include "virstring.h"
#include "storage_util.h"
#include "node_device_conf.h"
+#include "node_device_util.h"
#include "driver.h"
#define VIR_FROM_THIS VIR_FROM_STORAGE
--
2.19.1
5 years, 11 months
[libvirt] [PATCH] bt: Mark the bluetooth subsystem as deprecated
by Thomas Huth
It has been unmaintained since years, and there were only trivial or
tree-wide changes to the related files since many years, so the
code is likely very bitrotten and broken. For example the following
segfaults as soon as as you press a key:
qemu-system-x86_64 -usb -device usb-bt-dongle -bt hci -bt device:keyboard
Since we are not aware of anybody using bluetooth with the current
version of QEMU, let's mark the subsystem as deprecated, with a special
request for the users to write to the qemu-devel mailing list in case
they still use it (so we could revert the deprecation status in that
case).
Signed-off-by: Thomas Huth <thuth(a)redhat.com>
---
qemu-deprecated.texi | 7 +++++++
qemu-options.hx | 4 ++++
vl.c | 4 ++++
3 files changed, 15 insertions(+)
diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi
index 5d2d7a3..cb4291f 100644
--- a/qemu-deprecated.texi
+++ b/qemu-deprecated.texi
@@ -128,6 +128,13 @@ The @option{[hub_id name]} parameter tuple of the 'hostfwd_add' and
The ``ivshmem'' device type is replaced by either the ``ivshmem-plain''
or ``ivshmem-doorbell`` device types.
+@subsection bluetooth (since 3.1)
+
+The bluetooth subsystem is unmaintained since many years and likely bitrotten
+quite a bit. It will be removed without replacement unless some users speaks
+up at the @email{qemu-devel@(a)nongnu.org} mailing list with information about
+their usecases.
+
@section System emulator machines
@subsection pc-0.10 and pc-0.11 (since 3.0)
diff --git a/qemu-options.hx b/qemu-options.hx
index 38c7a97..ee379b3 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -2772,6 +2772,10 @@ logic. The Transport Layer is decided by the machine type. Currently
the machines @code{n800} and @code{n810} have one HCI and all other
machines have none.
+Note: This option and the whole bluetooth subsystem is considered as deprecated.
+If you still use it, please send a mail to @email{qemu-devel@(a)nongnu.org} where
+you describe your usecase.
+
@anchor{bt-hcis}
The following three types are recognized:
diff --git a/vl.c b/vl.c
index 55bab00..fa25d1a 100644
--- a/vl.c
+++ b/vl.c
@@ -3269,6 +3269,10 @@ int main(int argc, char **argv, char **envp)
break;
#endif
case QEMU_OPTION_bt:
+ warn_report("The bluetooth subsystem is deprecated and will "
+ "be removed soon. If the bluetooth subsystem is "
+ "still useful for you, please send a mail to "
+ "qemu-devel(a)nongnu.org with your usecase.");
add_device_config(DEV_BT, optarg);
break;
case QEMU_OPTION_audio_help:
--
1.8.3.1
5 years, 11 months
[libvirt] [PATCHv7 00/18] Introduce x86 Cache Monitoring Technology (CMT)
by Wang Huaqiang
This series of patches and the series already been merged introduce
the x86 Cache Monitoring Technology (CMT) to libvirt by interacting
with kernel resource control (resctrl) interface. CMT is one of the
Intel(R) x86 CPU feature which belongs to the Resource Director
Technology (RDT). CMT reports the occupancy of the last level cache,
which is shared by all CPU cores.
In the v1 series, an original and complete feature for CMT was introduced
The v2 and v3 patches address the feature for the host capability of CMT.
v4 is addressing the feature for monitoring VM vcpu thread set cache
occupancy and reporting it through a virsh command.
We have serval discussion about the enabling of CMT, please refer to
following links for the RFCs.
RFCv3
https://www.redhat.com/archives/libvir-list/2018-August/msg01213.html
RFCv2
https://www.redhat.com/archives/libvir-list/2018-July/msg00409.html
https://www.redhat.com/archives/libvir-list/2018-July/msg01241.html
RFCv1
https://www.redhat.com/archives/libvir-list/2018-June/msg00674.html
And the merged commits are list as below, for host capability of CMT.
6af8417415508c31f8ce71234b573b4999f35980
8f6887998bf63594ae26e3db18d4d5896c5f2cb4
58fcee6f3a2b7e89c21c1fb4ec21429c31a0c5b8
12093f1feaf8f5023dcd9d65dff111022842183d
a5d293c18831dcf69ec6195798387fbb70c9f461
1. About reason why CMT is necessary in libvirt?
The perf events of 'CMT, MBML, MBMT' have been phased out since Linux
kernel commit c39a0e2c8850f08249383f2425dbd8dbe4baad69, in libvirt
the perf based cmt,mbm will not work with the latest linux kernel. These
patches add CMT feature to libvirt through kernel resctrlfs interface.
2 Create cache monitoring group (cache monitor).
The main interface for creating monitoring group is through XML file. The
proposed configuration is like:
<cputune>
<cachetune vcpus='1'>
<cache id='0' level='3' type='code' size='7680' unit='KiB'/>
<cache id='1' level='3' type='data' size='3840' unit='KiB'/>
+ <monitor level='3' vcpus='1'/>
</cachetune>
<cachetune vcpus='4-7'>
+ <monitor level='3' vcpus='4-6'/>
</cachetune>
</cputune>
In above XML, created 2 cache resctrl allocation groups and 2 resctrl
monitoring groups.
The changes of cache monitor will be effective in next booting of VM.
2 Show CMT result through command 'domstats'
Adding the interface in qemu to report this information for resource
monitor group through command 'virsh domstats --cpu-total'.
Below is a typical output:
# virsh domstats 1 --cpu-total
Domain: 'ubuntu16.04-base'
...
cpu.cache.monitor.count=2
cpu.cache.monitor.0.name=vcpus_1
cpu.cache.monitor.0.vcpus=1
cpu.cache.monitor.0.bank.count=2
cpu.cache.monitor.0.bank.0.id=0
cpu.cache.monitor.0.bank.0.bytes=4505600
cpu.cache.monitor.0.bank.1.id=1
cpu.cache.monitor.0.bank.1.bytes=5586944
cpu.cache.monitor.1.name=vcpus_4-6
cpu.cache.monitor.1.vcpus=4,5,6
cpu.cache.monitor.1.bank.count=2
cpu.cache.monitor.1.bank.0.id=0
cpu.cache.monitor.1.bank.0.bytes=17571840
cpu.cache.monitor.1.bank.1.id=1
cpu.cache.monitor.1.bank.1.bytes=29106176
Changes in v7:
- Add several lines removed by mistake.
Changes in v6:
- Addressing John's review comments for v5.
- Removed and cleaned the concepts of 'default allocation' and
'default monitor'.
- qemu: virsh domstats --cpu-total output for CMT, add identifier
'monitor' for each itm.
Changes in v5:
- qemu: Setting up vcpu and adding pids to resctrl monitor groups during
re-connection.
- Add the document for domain configuration related to resctrl monitor.
Changes in v4:
v4 is addressing the feature for monitoring VM vcpu
thread set cache occupancy and reporting it through a
virsh command.
- Introduced resctrl default allocation
- Introduced resctrl monitor and default monitor
Changes in v3:
- Addressed John Ferlan's review.
- Typo fixed.
- Removed VIR_ENUM_DECL(virMonitor);
Changes in v2:
- Introduced MBM capability.
- Capability layout changed
* Moved <monitor> from cahe <bank> to <cache>
* Renamed <Threshold> to <reuseThreshold>
- Document for 'reuseThreshold' changed.
- Introduced API virResctrlInfoGetMonitorPrefix
- Added more tests, covering standalone CMT, fake new
feature.
- Creating CMT resource control group will be
subsequent job.
Wang Huaqiang (18):
docs,util: Refactor schemas and virresctrl to support optional cache
util: Introduce resctrl monitor for CMT
util: Refactor code for determining allocation path
util: Add interface to determine monitor path
util: Refactor code for adding PID to the resource group
util: Add interface for adding PID to the monitor
util: Refactor code for creating resctrl group
util: Add interface for creating monitor group
util: Add more interfaces for resctrl monitor
conf: Remove virDomainResctrlAppend and introduce virDomainResctrlNew
conf: move virResctrlAllocIsEmpty to a place a litter lower
conf: Introduce cache monitor element in cachetune
qemu: enable resctrl monitor in qemu
util: Add function for checking if monitor is running
conf: Add 'id' to virDomainResctrlDef
qemu: refactor qemuDomainGetStatsCpu
qemu: Report cache occupancy (CMT) with domstats
qemu: Setting up vcpu and adding pids to resctrl monitor groups during
reconnection
docs/formatdomain.html.in | 30 +-
docs/schemas/domaincommon.rng | 14 +-
src/conf/domain_conf.c | 310 ++++++++++--
src/conf/domain_conf.h | 12 +
src/libvirt-domain.c | 9 +
src/libvirt_private.syms | 11 +
src/qemu/qemu_driver.c | 270 +++++++++-
src/qemu/qemu_process.c | 69 ++-
src/util/virresctrl.c | 560 +++++++++++++++++++--
src/util/virresctrl.h | 49 ++
tests/genericxml2xmlindata/cachetune-cdp.xml | 3 +
.../cachetune-colliding-monitor.xml | 30 ++
tests/genericxml2xmlindata/cachetune-small.xml | 7 +
tests/genericxml2xmltest.c | 2 +
14 files changed, 1283 insertions(+), 93 deletions(-)
create mode 100644 tests/genericxml2xmlindata/cachetune-colliding-monitor.xml
--
2.7.4
5 years, 11 months
[libvirt] [PATCH] nodedev: Add new module node_device_util
by Erik Skultety
There's a lot of stuff going on in src/conf/nodedev_conf which not
always has to do anything with config, so even though we're trying,
we're not really consistent in putting only parser/formatter related
stuff here like we do for domains. So, start the cleanup simply by adding
a new module to the nodedev driver and put a few helper APIs which want
to open a secondary driver connection in there (similar to storage_util
module).
Signed-off-by: Erik Skultety <eskultet(a)redhat.com>
---
I verified the build with debian 9, centos 7, fedora 28, rawhide, and freebsd
11
src/conf/Makefile.inc.am | 1 +
src/conf/node_device_conf.c | 199 -----------------------
src/conf/node_device_conf.h | 11 --
src/conf/virstorageobj.c | 1 +
src/libvirt_private.syms | 8 +-
src/node_device/Makefile.inc.am | 17 +-
src/node_device/node_device_driver.c | 1 +
src/node_device/node_device_util.c | 229 +++++++++++++++++++++++++++
src/node_device/node_device_util.h | 35 ++++
src/storage/Makefile.inc.am | 1 +
src/storage/storage_backend_scsi.c | 1 +
11 files changed, 290 insertions(+), 214 deletions(-)
create mode 100644 src/node_device/node_device_util.c
create mode 100644 src/node_device/node_device_util.h
diff --git a/src/conf/Makefile.inc.am b/src/conf/Makefile.inc.am
index af23810640..7cb6c29d70 100644
--- a/src/conf/Makefile.inc.am
+++ b/src/conf/Makefile.inc.am
@@ -163,6 +163,7 @@ libvirt_la_BUILT_LIBADD += libvirt_conf.la
libvirt_conf_la_SOURCES = $(CONF_SOURCES)
libvirt_conf_la_CFLAGS = \
-I$(srcdir)/conf \
+ -I$(srcdir)/node_device \
$(AM_CFLAGS) \
$(NULL)
libvirt_conf_la_LDFLAGS = $(AM_LDFLAGS)
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index 03bd794dc0..74a7bc3933 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -2220,205 +2220,6 @@ virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps)
}
-/* virNodeDeviceGetParentName
- * @conn: Connection pointer
- * @nodedev_name: Node device to lookup
- *
- * Lookup the node device by name and return the parent name
- *
- * Returns parent name on success, caller is responsible for freeing;
- * otherwise, returns NULL on failure
- */
-char *
-virNodeDeviceGetParentName(virConnectPtr conn,
- const char *nodedev_name)
-{
- virNodeDevicePtr device = NULL;
- char *parent;
-
- if (!(device = virNodeDeviceLookupByName(conn, nodedev_name))) {
- virReportError(VIR_ERR_XML_ERROR,
- _("Cannot find '%s' in node device database"),
- nodedev_name);
- return NULL;
- }
-
- ignore_value(VIR_STRDUP(parent, virNodeDeviceGetParent(device)));
- virObjectUnref(device);
-
- return parent;
-}
-
-
-/**
- * @fchost: Pointer to vHBA adapter
- *
- * Create a vHBA for Storage. This code accomplishes this via searching
- * through the sysfs for scsi_host/fc_host in order to first ensure some
- * vHBA doesn't already exist for the requested wwnn/wwpn (e.g. an unmanaged
- * vHBA) and to search for the parent vport capable scsi_host by name,
- * wwnn/wwpn, or fabric_wwn (if provided). If no parent is provided, then
- * a vport capable scsi_host will be selected.
- *
- * Returns vHBA name on success, NULL on failure with an error message set
- */
-char *
-virNodeDeviceCreateVport(virStorageAdapterFCHostPtr fchost)
-{
- unsigned int parent_host;
- char *name = NULL;
- char *parent_hoststr = NULL;
- bool skip_capable_check = false;
-
- VIR_DEBUG("parent='%s', wwnn='%s' wwpn='%s'",
- NULLSTR(fchost->parent), fchost->wwnn, fchost->wwpn);
-
- if (fchost->parent) {
- if (VIR_STRDUP(parent_hoststr, fchost->parent) < 0)
- goto cleanup;
- } else if (fchost->parent_wwnn && fchost->parent_wwpn) {
- if (!(parent_hoststr = virVHBAGetHostByWWN(NULL, fchost->parent_wwnn,
- fchost->parent_wwpn))) {
- virReportError(VIR_ERR_XML_ERROR, "%s",
- _("cannot find parent using provided wwnn/wwpn"));
- goto cleanup;
- }
- } else if (fchost->parent_fabric_wwn) {
- if (!(parent_hoststr =
- virVHBAGetHostByFabricWWN(NULL, fchost->parent_fabric_wwn))) {
- virReportError(VIR_ERR_XML_ERROR, "%s",
- _("cannot find parent using provided fabric_wwn"));
- goto cleanup;
- }
- } else {
- if (!(parent_hoststr = virVHBAFindVportHost(NULL))) {
- virReportError(VIR_ERR_XML_ERROR, "%s",
- _("'parent' for vHBA not specified, and "
- "cannot find one on this host"));
- goto cleanup;
- }
- skip_capable_check = true;
- }
-
- if (virSCSIHostGetNumber(parent_hoststr, &parent_host) < 0)
- goto cleanup;
-
- /* NOTE:
- * We do not save the parent_hoststr in fchost->parent since
- * we could be writing out the 'def' to the saved XML config.
- * If we wrote out the name in the XML, then future starts would
- * always use the same parent rather than finding the "best available"
- * parent. Besides we have a way to determine the parent based on
- * the 'name' field.
- */
- if (!skip_capable_check && !virVHBAPathExists(NULL, parent_host)) {
- virReportError(VIR_ERR_XML_ERROR,
- _("parent '%s' specified for vHBA does not exist"),
- parent_hoststr);
- goto cleanup;
- }
-
- if (virVHBAManageVport(parent_host, fchost->wwpn, fchost->wwnn,
- VPORT_CREATE) < 0)
- goto cleanup;
-
- /* Let's ensure the device was created */
- virWaitForDevices();
- if (!(name = virVHBAGetHostByWWN(NULL, fchost->wwnn, fchost->wwpn))) {
- ignore_value(virVHBAManageVport(parent_host, fchost->wwpn, fchost->wwnn,
- VPORT_DELETE));
- goto cleanup;
- }
-
- cleanup:
- VIR_FREE(parent_hoststr);
- return name;
-}
-
-
-/**
- * @conn: Connection pointer
- * @fchost: Pointer to vHBA adapter
- *
- * As long as the vHBA is being managed, search for the scsi_host via the
- * provided wwnn/wwpn and then find the corresponding parent scsi_host in
- * order to send the delete request.
- *
- * Returns 0 on success, -1 on failure
- */
-int
-virNodeDeviceDeleteVport(virConnectPtr conn,
- virStorageAdapterFCHostPtr fchost)
-{
- char *name = NULL;
- char *scsi_host_name = NULL;
- unsigned int parent_host;
- char *vhba_parent = NULL;
- int ret = -1;
-
- VIR_DEBUG("conn=%p parent='%s', managed='%d' wwnn='%s' wwpn='%s'",
- conn, NULLSTR(fchost->parent), fchost->managed,
- fchost->wwnn, fchost->wwpn);
-
- /* If we're not managing the deletion of the vHBA, then just return */
- if (fchost->managed != VIR_TRISTATE_BOOL_YES)
- return 0;
-
- /* Find our vHBA by searching the fc_host sysfs tree for our wwnn/wwpn */
- if (!(name = virVHBAGetHostByWWN(NULL, fchost->wwnn, fchost->wwpn))) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Failed to find fc_host for wwnn='%s' and wwpn='%s'"),
- fchost->wwnn, fchost->wwpn);
- goto cleanup;
- }
-
- if (virAsprintf(&scsi_host_name, "scsi_%s", name) < 0)
- goto cleanup;
-
- /* If at startup time we provided a parent, then use that to
- * get the parent_host value; otherwise, we have to determine
- * the parent scsi_host which we did not save at startup time
- */
- if (fchost->parent) {
- /* Someone provided a parent string at startup time that
- * was the same as the scsi_host - meaning we have a pool
- * backed to an HBA, so there won't be a vHBA to delete */
- if (STREQ(scsi_host_name, fchost->parent)) {
- ret = 0;
- goto cleanup;
- }
-
- if (virSCSIHostGetNumber(fchost->parent, &parent_host) < 0)
- goto cleanup;
- } else {
- if (!(vhba_parent = virNodeDeviceGetParentName(conn, scsi_host_name)))
- goto cleanup;
-
- /* If the parent is not a scsi_host, then this is a pool backed
- * directly to an HBA and there's no vHBA to remove - so we're done */
- if (!STRPREFIX(vhba_parent, "scsi_host")) {
- ret = 0;
- goto cleanup;
- }
-
- if (virSCSIHostGetNumber(vhba_parent, &parent_host) < 0)
- goto cleanup;
- }
-
- if (virVHBAManageVport(parent_host, fchost->wwpn, fchost->wwnn,
- VPORT_DELETE) < 0)
- goto cleanup;
-
- ret = 0;
-
- cleanup:
- VIR_FREE(name);
- VIR_FREE(vhba_parent);
- VIR_FREE(scsi_host_name);
- return ret;
-}
-
-
int
virNodeDeviceUpdateCaps(virNodeDeviceDefPtr def)
{
diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h
index 685ae30347..fde239183d 100644
--- a/src/conf/node_device_conf.h
+++ b/src/conf/node_device_conf.h
@@ -367,17 +367,6 @@ virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps);
VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV | \
VIR_CONNECT_LIST_NODE_DEVICES_CAP_CCW_DEV)
-char *
-virNodeDeviceGetParentName(virConnectPtr conn,
- const char *nodedev_name);
-
-char *
-virNodeDeviceCreateVport(virStorageAdapterFCHostPtr fchost);
-
-int
-virNodeDeviceDeleteVport(virConnectPtr conn,
- virStorageAdapterFCHostPtr fchost);
-
int
virNodeDeviceGetSCSIHostCaps(virNodeDevCapSCSIHostPtr scsi_host);
diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c
index 0b3ba84af2..30aabb2b37 100644
--- a/src/conf/virstorageobj.c
+++ b/src/conf/virstorageobj.c
@@ -22,6 +22,7 @@
#include "datatypes.h"
#include "node_device_conf.h"
+#include "node_device_util.h"
#include "virstorageobj.h"
#include "viralloc.h"
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 335210c31d..e2f10acff4 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -722,14 +722,11 @@ virNodeDevCapsDefFree;
virNodeDevCapTypeFromString;
virNodeDevCapTypeToString;
virNodeDeviceCapsListExport;
-virNodeDeviceCreateVport;
virNodeDeviceDefFormat;
virNodeDeviceDefFree;
virNodeDeviceDefParseFile;
virNodeDeviceDefParseNode;
virNodeDeviceDefParseString;
-virNodeDeviceDeleteVport;
-virNodeDeviceGetParentName;
virNodeDeviceGetPCIDynamicCaps;
virNodeDeviceGetSCSIHostCaps;
virNodeDeviceGetSCSITargetCaps;
@@ -1317,6 +1314,11 @@ virLogManagerFree;
virLogManagerNew;
+# node_device/node_device_util.h
+virNodeDeviceCreateVport;
+virNodeDeviceDeleteVport;
+virNodeDeviceGetParentName;
+
# secret/secret_util.h
virSecretGetSecretString;
diff --git a/src/node_device/Makefile.inc.am b/src/node_device/Makefile.inc.am
index 0c3ad51273..f7aec97ba9 100644
--- a/src/node_device/Makefile.inc.am
+++ b/src/node_device/Makefile.inc.am
@@ -3,6 +3,11 @@ NODE_DEVICE_DRIVER_SOURCES = \
node_device/node_device_driver.h \
$(NULL)
+NODE_DEVICE_UTIL_SOURCES = \
+ node_device/node_device_util.h \
+ node_device/node_device_util.c \
+ $(NULL)
+
NODE_DEVICE_DRIVER_HAL_SOURCES = \
node_device/node_device_hal.c \
node_device/node_device_hal.h \
@@ -17,6 +22,7 @@ DRIVER_SOURCE_FILES += \
$(NODE_DEVICE_DRIVER_SOURCES) \
$(NODE_DEVICE_DRIVER_HAL_SOURCES) \
$(NODE_DEVICE_DRIVER_UDEV_SOURCES) \
+ $(NODE_DEVICE_UTIL_SOURCES) \
$(NULL)
STATEFUL_DRIVER_SOURCE_FILES += \
@@ -27,13 +33,22 @@ EXTRA_DIST += \
$(NODE_DEVICE_DRIVER_SOURCES) \
$(NODE_DEVICE_DRIVER_HAL_SOURCES) \
$(NODE_DEVICE_DRIVER_UDEV_SOURCES) \
+ $(NODE_DEVICE_UTIL_SOURCES) \
$(NULL)
+noinst_LTLIBRARIES += libvirt_nodedev.la
+libvirt_la_BUILT_LIBADD += libvirt_nodedev.la
+libvirt_nodedev_la_CFLAGS = $(AM_CFLAGS)
+libvirt_nodedev_la_LDFLAGS = $(AM_LDFLAGS)
+libvirt_nodedev_la_SOURCES = $(NODE_DEVICE_UTIL_SOURCES)
if WITH_NODE_DEVICES
# Needed to keep automake quiet about conditionals
mod_LTLIBRARIES += libvirt_driver_nodedev.la
-libvirt_driver_nodedev_la_SOURCES = $(NODE_DEVICE_DRIVER_SOURCES)
+libvirt_driver_nodedev_la_SOURCES = \
+ $(NODE_DEVICE_DRIVER_SOURCES) \
+ $(NODE_DEVICE_UTIL_SOURCES) \
+ $(NULL)
libvirt_driver_nodedev_la_CFLAGS = \
-I$(srcdir)/access \
diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index c46d0fbe12..0bcb3de053 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -37,6 +37,7 @@
#include "node_device_event.h"
#include "node_device_driver.h"
#include "node_device_hal.h"
+#include "node_device_util.h"
#include "virvhba.h"
#include "viraccessapicheck.h"
#include "virnetdev.h"
diff --git a/src/node_device/node_device_util.c b/src/node_device/node_device_util.c
new file mode 100644
index 0000000000..d1d9c3ee49
--- /dev/null
+++ b/src/node_device/node_device_util.c
@@ -0,0 +1,229 @@
+/*
+ * node_device_util.c: helper functions for the node device driver
+ *
+ * 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
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+
+#include "internal.h"
+
+#include "node_device_util.h"
+#include "virlog.h"
+#include "virscsihost.h"
+#include "virstring.h"
+#include "virvhba.h"
+
+#define VIR_FROM_THIS VIR_FROM_NODEDEV
+
+VIR_LOG_INIT("node_device.node_device_util");
+
+/* virNodeDeviceGetParentName
+ * @conn: Connection pointer
+ * @nodedev_name: Node device to lookup
+ *
+ * Lookup the node device by name and return the parent name
+ *
+ * Returns parent name on success, caller is responsible for freeing;
+ * otherwise, returns NULL on failure
+ */
+char *
+virNodeDeviceGetParentName(virConnectPtr conn,
+ const char *nodedev_name)
+{
+ virNodeDevicePtr device = NULL;
+ char *parent;
+
+ if (!(device = virNodeDeviceLookupByName(conn, nodedev_name))) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("Cannot find '%s' in node device database"),
+ nodedev_name);
+ return NULL;
+ }
+
+ ignore_value(VIR_STRDUP(parent, virNodeDeviceGetParent(device)));
+ virObjectUnref(device);
+
+ return parent;
+}
+
+
+/**
+ * @fchost: Pointer to vHBA adapter
+ *
+ * Create a vHBA for Storage. This code accomplishes this via searching
+ * through the sysfs for scsi_host/fc_host in order to first ensure some
+ * vHBA doesn't already exist for the requested wwnn/wwpn (e.g. an unmanaged
+ * vHBA) and to search for the parent vport capable scsi_host by name,
+ * wwnn/wwpn, or fabric_wwn (if provided). If no parent is provided, then
+ * a vport capable scsi_host will be selected.
+ *
+ * Returns vHBA name on success, NULL on failure with an error message set
+ */
+char *
+virNodeDeviceCreateVport(virStorageAdapterFCHostPtr fchost)
+{
+ unsigned int parent_host;
+ char *name = NULL;
+ char *parent_hoststr = NULL;
+ bool skip_capable_check = false;
+
+ VIR_DEBUG("parent='%s', wwnn='%s' wwpn='%s'",
+ NULLSTR(fchost->parent), fchost->wwnn, fchost->wwpn);
+
+ if (fchost->parent) {
+ if (VIR_STRDUP(parent_hoststr, fchost->parent) < 0)
+ goto cleanup;
+ } else if (fchost->parent_wwnn && fchost->parent_wwpn) {
+ if (!(parent_hoststr = virVHBAGetHostByWWN(NULL, fchost->parent_wwnn,
+ fchost->parent_wwpn))) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("cannot find parent using provided wwnn/wwpn"));
+ goto cleanup;
+ }
+ } else if (fchost->parent_fabric_wwn) {
+ if (!(parent_hoststr =
+ virVHBAGetHostByFabricWWN(NULL, fchost->parent_fabric_wwn))) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("cannot find parent using provided fabric_wwn"));
+ goto cleanup;
+ }
+ } else {
+ if (!(parent_hoststr = virVHBAFindVportHost(NULL))) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("'parent' for vHBA not specified, and "
+ "cannot find one on this host"));
+ goto cleanup;
+ }
+ skip_capable_check = true;
+ }
+
+ if (virSCSIHostGetNumber(parent_hoststr, &parent_host) < 0)
+ goto cleanup;
+
+ /* NOTE:
+ * We do not save the parent_hoststr in fchost->parent since
+ * we could be writing out the 'def' to the saved XML config.
+ * If we wrote out the name in the XML, then future starts would
+ * always use the same parent rather than finding the "best available"
+ * parent. Besides we have a way to determine the parent based on
+ * the 'name' field.
+ */
+ if (!skip_capable_check && !virVHBAPathExists(NULL, parent_host)) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("parent '%s' specified for vHBA does not exist"),
+ parent_hoststr);
+ goto cleanup;
+ }
+
+ if (virVHBAManageVport(parent_host, fchost->wwpn, fchost->wwnn,
+ VPORT_CREATE) < 0)
+ goto cleanup;
+
+ /* Let's ensure the device was created */
+ virWaitForDevices();
+ if (!(name = virVHBAGetHostByWWN(NULL, fchost->wwnn, fchost->wwpn))) {
+ ignore_value(virVHBAManageVport(parent_host, fchost->wwpn, fchost->wwnn,
+ VPORT_DELETE));
+ goto cleanup;
+ }
+
+ cleanup:
+ VIR_FREE(parent_hoststr);
+ return name;
+}
+
+
+/**
+ * @conn: Connection pointer
+ * @fchost: Pointer to vHBA adapter
+ *
+ * As long as the vHBA is being managed, search for the scsi_host via the
+ * provided wwnn/wwpn and then find the corresponding parent scsi_host in
+ * order to send the delete request.
+ *
+ * Returns 0 on success, -1 on failure
+ */
+int
+virNodeDeviceDeleteVport(virConnectPtr conn,
+ virStorageAdapterFCHostPtr fchost)
+{
+ char *name = NULL;
+ char *scsi_host_name = NULL;
+ unsigned int parent_host;
+ char *vhba_parent = NULL;
+ int ret = -1;
+
+ VIR_DEBUG("conn=%p parent='%s', managed='%d' wwnn='%s' wwpn='%s'",
+ conn, NULLSTR(fchost->parent), fchost->managed,
+ fchost->wwnn, fchost->wwpn);
+
+ /* If we're not managing the deletion of the vHBA, then just return */
+ if (fchost->managed != VIR_TRISTATE_BOOL_YES)
+ return 0;
+
+ /* Find our vHBA by searching the fc_host sysfs tree for our wwnn/wwpn */
+ if (!(name = virVHBAGetHostByWWN(NULL, fchost->wwnn, fchost->wwpn))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to find fc_host for wwnn='%s' and wwpn='%s'"),
+ fchost->wwnn, fchost->wwpn);
+ goto cleanup;
+ }
+
+ if (virAsprintf(&scsi_host_name, "scsi_%s", name) < 0)
+ goto cleanup;
+
+ /* If at startup time we provided a parent, then use that to
+ * get the parent_host value; otherwise, we have to determine
+ * the parent scsi_host which we did not save at startup time
+ */
+ if (fchost->parent) {
+ /* Someone provided a parent string at startup time that
+ * was the same as the scsi_host - meaning we have a pool
+ * backed to an HBA, so there won't be a vHBA to delete */
+ if (STREQ(scsi_host_name, fchost->parent)) {
+ ret = 0;
+ goto cleanup;
+ }
+
+ if (virSCSIHostGetNumber(fchost->parent, &parent_host) < 0)
+ goto cleanup;
+ } else {
+ if (!(vhba_parent = virNodeDeviceGetParentName(conn, scsi_host_name)))
+ goto cleanup;
+
+ /* If the parent is not a scsi_host, then this is a pool backed
+ * directly to an HBA and there's no vHBA to remove - so we're done */
+ if (!STRPREFIX(vhba_parent, "scsi_host")) {
+ ret = 0;
+ goto cleanup;
+ }
+
+ if (virSCSIHostGetNumber(vhba_parent, &parent_host) < 0)
+ goto cleanup;
+ }
+
+ if (virVHBAManageVport(parent_host, fchost->wwpn, fchost->wwnn,
+ VPORT_DELETE) < 0)
+ goto cleanup;
+
+ ret = 0;
+
+ cleanup:
+ VIR_FREE(name);
+ VIR_FREE(vhba_parent);
+ VIR_FREE(scsi_host_name);
+ return ret;
+}
diff --git a/src/node_device/node_device_util.h b/src/node_device/node_device_util.h
new file mode 100644
index 0000000000..5cb225d03e
--- /dev/null
+++ b/src/node_device/node_device_util.h
@@ -0,0 +1,35 @@
+/*
+ * node_device_util.h: utility functions for node device driver
+ *
+ * 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
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __VIR_NODE_DEVICE_UTIL_H__
+# define __VIR_NODE_DEVICE_UTIL_H__
+
+# include "conf/storage_adapter_conf.h"
+
+char *
+virNodeDeviceGetParentName(virConnectPtr conn,
+ const char *nodedev_name);
+
+char *
+virNodeDeviceCreateVport(virStorageAdapterFCHostPtr fchost);
+
+int
+virNodeDeviceDeleteVport(virConnectPtr conn,
+ virStorageAdapterFCHostPtr fchost);
+
+#endif /* __VIR_NODE_DEVICE_UTIL_H__ */
diff --git a/src/storage/Makefile.inc.am b/src/storage/Makefile.inc.am
index b4400b556f..c1fd8cc7b3 100644
--- a/src/storage/Makefile.inc.am
+++ b/src/storage/Makefile.inc.am
@@ -221,6 +221,7 @@ if WITH_STORAGE_SCSI
libvirt_storage_backend_scsi_la_SOURCES = $(STORAGE_DRIVER_SCSI_SOURCES)
libvirt_storage_backend_scsi_la_CFLAGS = \
-I$(srcdir)/conf \
+ -I$(srcdir)/node_device \
$(AM_CFLAGS) \
$(NULL)
diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c
index 7c927c4d95..fe3a1e36ac 100644
--- a/src/storage/storage_backend_scsi.c
+++ b/src/storage/storage_backend_scsi.c
@@ -35,6 +35,7 @@
#include "virstring.h"
#include "storage_util.h"
#include "node_device_conf.h"
+#include "node_device_util.h"
#include "driver.h"
#define VIR_FROM_THIS VIR_FROM_STORAGE
--
2.17.2
5 years, 11 months
[libvirt] [tck PATCH 0/3] Improvements to virtual network testing and misc fixes
by Daniel P. Berrangé
The main goal of this patch series is addition of tests which create
a virtual network with every possible forwarding mode, and attempt to
boot a guest with them. A couple of other pieces were added at the end.
Daniel P. Berrangé (3):
Add tests for virtual network <-> guest connections
Fix incorrect warning about deleting everything
Allow tests to be listed as positional arguments
bin/libvirt-tck | 69 ++++++++-------
lib/Sys/Virt/TCK.pm | 33 ++++++++
lib/Sys/Virt/TCK/NetworkBuilder.pm | 33 +++++++-
scripts/networks/300-guest-network-isolated.t | 82 ++++++++++++++++++
scripts/networks/310-guest-network-nat.t | 83 +++++++++++++++++++
scripts/networks/320-guest-network-route.t | 83 +++++++++++++++++++
scripts/networks/330-guest-network-open.t | 83 +++++++++++++++++++
scripts/networks/340-guest-network-bridge.t | 79 ++++++++++++++++++
scripts/networks/350-guest-network-private.t | 81 ++++++++++++++++++
scripts/networks/360-guest-network-vepa.t | 81 ++++++++++++++++++
.../networks/370-guest-network-passthrough.t | 81 ++++++++++++++++++
scripts/networks/380-guest-network-hostdev.t | 82 ++++++++++++++++++
t/080-network-builder.t | 2 +-
13 files changed, 838 insertions(+), 34 deletions(-)
create mode 100644 scripts/networks/300-guest-network-isolated.t
create mode 100644 scripts/networks/310-guest-network-nat.t
create mode 100644 scripts/networks/320-guest-network-route.t
create mode 100644 scripts/networks/330-guest-network-open.t
create mode 100644 scripts/networks/340-guest-network-bridge.t
create mode 100644 scripts/networks/350-guest-network-private.t
create mode 100644 scripts/networks/360-guest-network-vepa.t
create mode 100644 scripts/networks/370-guest-network-passthrough.t
create mode 100644 scripts/networks/380-guest-network-hostdev.t
--
2.19.1
5 years, 11 months