libvirt-7.3.0-1.el9

- Rebased to libvirt-7.3.0 (rhbz#1950948)
- The rebase also fixes the following bugs:
    rhbz#1898526, rhbz#1910617, rhbz#1910618, rhbz#1943392, rhbz#1946918
    rhbz#1947718, rhbz#1947720, rhbz#1947824, rhbz#1949342, rhbz#1950228
    rhbz#1950301, rhbz#1950601, rhbz#1950948, rhbz#1953939, rhbz#1958302
    rhbz#1962053
- RHEL: Enable usage of x-blockdev-reopen (rhbz#1953939)
- RHEL: Add gating.yaml for RHEL9 (rhbz#1950601)
Resolves: rhbz#1898526, rhbz#1910617, rhbz#1910618, rhbz#1943392, rhbz#1946918
Resolves: rhbz#1947718, rhbz#1947720, rhbz#1947824, rhbz#1949342, rhbz#1950228
Resolves: rhbz#1950301, rhbz#1950601, rhbz#1950948, rhbz#1953939, rhbz#1958302
Resolves: rhbz#1962053
This commit is contained in:
Jiri Denemark 2021-05-24 18:44:48 +02:00
parent c51fcc467d
commit f99fdbd1ec
13 changed files with 2241 additions and 117 deletions

View File

@ -1,60 +0,0 @@
From b776d049b8c89b033004ad9502270d4b255a1958 Mon Sep 17 00:00:00 2001
From: Laine Stump <laine@redhat.com>
Date: Thu, 21 Jan 2021 16:01:06 -0500
Subject: [PATCH 1/2] build: support explicitly disabling netcf
placing "-Dnetcf=disabled" on the meson commandline was ignored,
meaning that even with that option the build would get WITH_NETCF if
the netcf-devel package was found - the only way to disable it was to
uninstall netcf-devel.
This patch adds the small bit of logic to check the netcf meson
commandline option (in addition to whether netcf-devel is installed)
before defining WITH_NETCF.
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 06169a115d46d8870a96d293c2faf6ea87e71020)
---
meson.build | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/meson.build b/meson.build
index b5164f68ed..e9d6d9f82e 100644
--- a/meson.build
+++ b/meson.build
@@ -1155,8 +1155,10 @@ libm_dep = cc.find_library('m', required : false)
netcf_version = '0.1.8'
netcf_dep = dependency('netcf', version: '>=' + netcf_version, required: get_option('netcf'))
-if netcf_dep.found()
- conf.set('WITH_NETCF', 1)
+if not get_option('netcf').disabled()
+ if netcf_dep.found()
+ conf.set('WITH_NETCF', 1)
+ endif
endif
have_gnu_gettext_tools = false
@@ -1550,7 +1552,7 @@ elif get_option('driver_hyperv').enabled()
error('openwsman is required for the Hyper-V driver')
endif
-if not get_option('driver_interface').disabled() and conf.has('WITH_LIBVIRTD') and (udev_dep.found() or netcf_dep.found())
+if not get_option('driver_interface').disabled() and conf.has('WITH_LIBVIRTD') and (udev_dep.found() or conf.has('WITH_NETCF'))
conf.set('WITH_INTERFACE', 1)
elif get_option('driver_interface').enabled()
error('Requested the Interface driver without netcf or udev and libvirtd support')
@@ -2362,7 +2364,7 @@ libs_summary = {
'libssh': libssh_dep.found(),
'libssh2': libssh2_dep.found(),
'libutil': libutil_dep.found(),
- 'netcf': netcf_dep.found(),
+ 'netcf': conf.has('WITH_NETCF'),
'NLS': have_gnu_gettext_tools,
'numactl': numactl_dep.found(),
'openwsman': openwsman_dep.found(),
--
2.29.2

7
gating.yaml Normal file
View File

@ -0,0 +1,7 @@
--- !Policy
product_versions:
- rhel-9
decision_context: osci_compose_gate
rules:
- !PassingTestCaseRule {test_case_name: libvirt-ci.libvirt.brew-build.gating.x86_64.tier1.functional}
- !PassingTestCaseRule {test_case_name: libvirt-ci.libvirt-python.brew-build.gating.x86_64.tier1.functional}

View File

@ -0,0 +1,182 @@
From 99c1665ce717c86ae8bc300259fbc246cdf9ae06 Mon Sep 17 00:00:00 2001
Message-Id: <99c1665ce717c86ae8bc300259fbc246cdf9ae06@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Mon, 16 Mar 2020 22:12:34 +0100
Subject: [PATCH] RHEL: Enable usage of x-blockdev-reopen
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
RHEL-only
Introduce a new capability QEMU_CAPS_BLOCKDEV_REOPEN_COM_REDHAT_AV_8_2_0_API
based on the presence of '__com.redhat_rhel-av-8_2_0-api' feature for
'x-blockdev-reopen' which states that reopen works for what libvirt
is going to use it and wire up code to call the x- prefixed command.
This implementation will become dormant once qemu starts supporting
upstream-stable blockdev-reopen.
https://bugzilla.redhat.com/show_bug.cgi?id=1953939
Message-Id: <098dc0e73e1b561af991f2a9ecf13436dde3b33d.1584391727.git.pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/qemu/qemu_block.c | 3 ++-
src/qemu/qemu_capabilities.c | 11 +++++++++++
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_monitor.c | 5 +++--
src/qemu/qemu_monitor.h | 3 ++-
src/qemu/qemu_monitor_json.c | 12 +++++++++---
src/qemu/qemu_monitor_json.h | 3 ++-
7 files changed, 30 insertions(+), 8 deletions(-)
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index 89f20eb1d2..e738433b04 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -3305,6 +3305,7 @@ qemuBlockReopenFormat(virDomainObj *vm,
qemuDomainObjPrivate *priv = vm->privateData;
virQEMUDriver *driver = priv->driver;
g_autoptr(virJSONValue) reopenprops = NULL;
+ bool downstream = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV_REOPEN_COM_REDHAT_AV_8_2_0_API);
int rc;
/* If we are lacking the object here, qemu might have opened an image with
@@ -3321,7 +3322,7 @@ qemuBlockReopenFormat(virDomainObj *vm,
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
return -1;
- rc = qemuMonitorBlockdevReopen(priv->mon, &reopenprops);
+ rc = qemuMonitorBlockdevReopen(priv->mon, &reopenprops, downstream);
if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0)
return -1;
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 7971a9c557..e2f4d6af7e 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -629,6 +629,7 @@ VIR_ENUM_IMPL(virQEMUCaps,
/* 400 */
"compat-deprecated",
"acpi-index",
+ "blockdev-reopen.__com.redhat_rhel-av-8_2_0-api",
);
@@ -1542,6 +1543,7 @@ static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsVhostUserFS[] =
/* see documentation for virQEMUQAPISchemaPathGet for the query format */
static struct virQEMUCapsStringFlags virQEMUCapsQMPSchemaQueries[] = {
+ { "x-blockdev-reopen/$__com.redhat_rhel-av-8_2_0-api", QEMU_CAPS_BLOCKDEV_REOPEN_COM_REDHAT_AV_8_2_0_API },
{ "blockdev-add/arg-type/options/+gluster/debug-level", QEMU_CAPS_GLUSTER_DEBUG_LEVEL},
{ "blockdev-add/arg-type/+gluster/debug", QEMU_CAPS_GLUSTER_DEBUG_LEVEL},
{ "blockdev-add/arg-type/+vxhs", QEMU_CAPS_VXHS},
@@ -5323,6 +5325,15 @@ virQEMUCapsInitProcessCaps(virQEMUCaps *qemuCaps)
qemuCaps->arch == VIR_ARCH_MIPS)
virQEMUCapsSet(qemuCaps, QEMU_CAPS_SCSI_NCR53C90);
+ /* RHEL-only:
+ * - if upstream blockdev-reopen is enabled, clear the downstream flag
+ * - if the downstream flag is present but not the upstream, assert the upstream flag too
+ */
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV_REOPEN))
+ virQEMUCapsClear(qemuCaps, QEMU_CAPS_BLOCKDEV_REOPEN_COM_REDHAT_AV_8_2_0_API);
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV_REOPEN_COM_REDHAT_AV_8_2_0_API))
+ virQEMUCapsSet(qemuCaps, QEMU_CAPS_BLOCKDEV_REOPEN);
+
virQEMUCapsInitProcessCapsInterlock(qemuCaps);
}
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index f54aad5dfd..51e256e317 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -609,6 +609,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */
/* 400 */
QEMU_CAPS_COMPAT_DEPRECATED, /* -compat deprecated-(input|output) is supported */
QEMU_CAPS_ACPI_INDEX, /* PCI device 'acpi-index' property */
+ QEMU_CAPS_BLOCKDEV_REOPEN_COM_REDHAT_AV_8_2_0_API, /* downstream support for blockdev reopen in rhel-av-8.2.0 */
QEMU_CAPS_LAST /* this must always be the last item */
} virQEMUCapsFlags;
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 23161a0088..d5b53975f6 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -4484,14 +4484,15 @@ qemuMonitorBlockdevAdd(qemuMonitor *mon,
int
qemuMonitorBlockdevReopen(qemuMonitor *mon,
- virJSONValue **props)
+ virJSONValue **props,
+ bool downstream)
{
VIR_DEBUG("props=%p (node-name=%s)", *props,
NULLSTR(virJSONValueObjectGetString(*props, "node-name")));
QEMU_CHECK_MONITOR(mon);
- return qemuMonitorJSONBlockdevReopen(mon, props);
+ return qemuMonitorJSONBlockdevReopen(mon, props, downstream);
}
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 420a85942a..759f9e1284 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -1374,7 +1374,8 @@ int qemuMonitorBlockdevAdd(qemuMonitor *mon,
virJSONValue **props);
int qemuMonitorBlockdevReopen(qemuMonitor *mon,
- virJSONValue **props);
+ virJSONValue **props,
+ bool downstream);
int qemuMonitorBlockdevDel(qemuMonitor *mon,
const char *nodename);
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 8de0e4b638..702c6fb8a1 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -8836,13 +8836,19 @@ qemuMonitorJSONBlockdevAdd(qemuMonitor *mon,
int
qemuMonitorJSONBlockdevReopen(qemuMonitor *mon,
- virJSONValue **props)
+ virJSONValue **props,
+ bool downstream)
{
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
- if (!(cmd = qemuMonitorJSONMakeCommandInternal("blockdev-reopen", props)))
- return -1;
+ if (downstream) {
+ if (!(cmd = qemuMonitorJSONMakeCommandInternal("x-blockdev-reopen", props)))
+ return -1;
+ } else {
+ if (!(cmd = qemuMonitorJSONMakeCommandInternal("blockdev-reopen", props)))
+ return -1;
+ }
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
return -1;
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 8d8f2de479..b42fb8f83e 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -607,7 +607,8 @@ int qemuMonitorJSONBlockdevAdd(qemuMonitor *mon,
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
int qemuMonitorJSONBlockdevReopen(qemuMonitor *mon,
- virJSONValue **props)
+ virJSONValue **props,
+ bool downstream)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
int qemuMonitorJSONBlockdevDel(qemuMonitor *mon,
--
2.31.1

View File

@ -0,0 +1,46 @@
From 3ba196a5b2135dcafec1d5377fc331772a6e11fa Mon Sep 17 00:00:00 2001
Message-Id: <3ba196a5b2135dcafec1d5377fc331772a6e11fa@dist-git>
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
Date: Mon, 27 Aug 2018 13:09:38 +0200
Subject: [PATCH] RHEL: Fix virConnectGetMaxVcpus output
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
https://bugzilla.redhat.com/show_bug.cgi?id=1092363
RHEL-only.
Ignore the maximum vcpu limit (KVM_CAP_MAX_VCPUS) on RHEL,
since RHEL QEMU treats the recommended limit (KVM_CAP_NR_VCPUS)
as the maximum, see:
https://bugzilla.redhat.com/show_bug.cgi?id=998708
(cherry picked from commit 7dff909fa34bdd93ad200dbffe70c0c1ee931925)
Signed-off-by: Ján Tomko <jtomko@redhat.com>
https: //bugzilla.redhat.com/show_bug.cgi?id=1582222
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
---
src/util/virhostcpu.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c
index bf7fda23af..0dfa56b8d7 100644
--- a/src/util/virhostcpu.c
+++ b/src/util/virhostcpu.c
@@ -1192,6 +1192,11 @@ virHostCPUGetKVMMaxVCPUs(void)
return -1;
}
+/* Ignore KVM_CAP_MAX_VCPUS on RHEL - the recommended maximum
+ * is treated as a hard limit.
+ */
+# undef KVM_CAP_MAX_VCPUS
+
# ifdef KVM_CAP_MAX_VCPUS
/* at first try KVM_CAP_MAX_VCPUS to determine the maximum count */
if ((ret = ioctl(fd, KVM_CHECK_EXTENSION, KVM_CAP_MAX_VCPUS)) > 0)
--
2.31.1

View File

@ -0,0 +1,81 @@
From 5d6681c6117b2686c79f4748903bc3c209b5ab86 Mon Sep 17 00:00:00 2001
Message-Id: <5d6681c6117b2686c79f4748903bc3c209b5ab86@dist-git>
From: John Ferlan <jferlan@redhat.com>
Date: Mon, 17 Dec 2018 20:42:30 -0500
Subject: [PATCH] RHEL: qemu: Add ability to set sgio values for hostdev
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
https://bugzilla.redhat.com/show_bug.cgi?id=1582424
RHEL-only
Add necessary checks in order to allow setting sgio values for a scsi
host device
Signed-off-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
src/qemu/qemu_conf.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 916a3d36ee..a749fc1bbc 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1836,8 +1836,9 @@ qemuSetUnprivSGIO(virDomainDeviceDef *dev)
virDomainDiskDef *disk = NULL;
virDomainHostdevDef *hostdev = NULL;
g_autofree char *sysfs_path = NULL;
+ g_autofree char *hostdev_path = NULL;
const char *path = NULL;
- int val = -1;
+ int val = 0;
/* "sgio" is only valid for block disk; cdrom
* and floopy disk can have empty source.
@@ -1853,17 +1854,14 @@ qemuSetUnprivSGIO(virDomainDeviceDef *dev)
} else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
hostdev = dev->data.hostdev;
- if (!qemuIsSharedHostdev(hostdev))
+ if (hostdev->source.subsys.u.scsi.protocol ==
+ VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)
return 0;
- if (hostdev->source.subsys.u.scsi.sgio) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("'sgio' is not supported for SCSI "
- "generic device yet "));
+ if (!(hostdev_path = qemuGetHostdevPath(hostdev)))
return -1;
- }
- return 0;
+ path = hostdev_path;
} else {
return 0;
}
@@ -1872,7 +1870,16 @@ qemuSetUnprivSGIO(virDomainDeviceDef *dev)
return -1;
/* By default, filter the SG_IO commands, i.e. set unpriv_sgio to 0. */
- val = (disk->sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED);
+ if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
+ if (disk->sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED)
+ val = 1;
+ } else {
+ /* Only settable if <shareable/> was present for hostdev */
+ if (qemuIsSharedHostdev(hostdev) &&
+ hostdev->source.subsys.u.scsi.sgio ==
+ VIR_DOMAIN_DEVICE_SGIO_UNFILTERED)
+ val = 1;
+ }
/* Do not do anything if unpriv_sgio is not supported by the kernel and the
* whitelist is enabled. But if requesting unfiltered access, always call
--
2.31.1

View File

@ -0,0 +1,66 @@
From 92a78c70050e7c37a0cbba1f2da8382fdf25d119 Mon Sep 17 00:00:00 2001
Message-Id: <92a78c70050e7c37a0cbba1f2da8382fdf25d119@dist-git>
From: John Ferlan <jferlan@redhat.com>
Date: Mon, 17 Dec 2018 20:42:31 -0500
Subject: [PATCH] RHEL: qemu: Add check for unpriv sgio for SCSI generic host
device
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
https://bugzilla.redhat.com/show_bug.cgi?id=1582424
RHEL-only
Check if the hostdev has set the sgio filtered/unfiltered and handle
appropriately.
This restores functionality removed by upstream commit id 'ce346623'
to remove sgio support for the SCSI generic host device.
Signed-off-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
src/qemu/qemu_conf.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index a749fc1bbc..2beef89cd1 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1743,13 +1743,29 @@ qemuSharedHostdevAddRemoveInternal(virQEMUDriver *driver,
{
g_autofree char *dev_path = NULL;
g_autofree char *key = NULL;
+ virDomainHostdevSubsysSCSI *scsisrc = &hostdev->source.subsys.u.scsi;
+ virDomainHostdevSubsysSCSIHost *scsihostsrc = &scsisrc->u.host;
int ret = -1;
if (!qemuIsSharedHostdev(hostdev))
return 0;
- if (!(dev_path = qemuGetHostdevPath(hostdev)) ||
- !(key = qemuGetSharedDeviceKey(dev_path)))
+ if (!(dev_path = qemuGetHostdevPath(hostdev)))
+ return -1;
+
+ if ((ret = qemuCheckUnprivSGIO(driver->sharedDevices, dev_path,
+ scsisrc->sgio)) < 0) {
+ if (ret == -2) {
+ virReportError(VIR_ERR_OPERATION_INVALID,
+ _("sgio of shared scsi host device '%s-%u-%u-%llu' "
+ "conflicts with other active domains"),
+ scsihostsrc->adapter, scsihostsrc->bus,
+ scsihostsrc->target, scsihostsrc->unit);
+ }
+ return -1;
+ }
+
+ if (!(key = qemuGetSharedDeviceKey(dev_path)))
return -1;
qemuDriverLock(driver);
--
2.31.1

View File

@ -0,0 +1,215 @@
From 62349827c097fe9a304c41cc6426369f81b27de8 Mon Sep 17 00:00:00 2001
Message-Id: <62349827c097fe9a304c41cc6426369f81b27de8@dist-git>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Fri, 6 Mar 2020 15:52:21 +0100
Subject: [PATCH] RHEL: virscsi: Check device type before getting it's /dev
node name
Not all SCSI devices are block devices, therefore
/sys/bus/scsi/devices/X:X:X:X/block/ directory does not always
exist. Check if the SCSI device is a block device beforehand.
https://bugzilla.redhat.com/show_bug.cgi?id=1808390
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Message-Id: <20200306145226.1610708-2-abologna@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
src/util/virscsi.c | 140 ++++++++++++++++++++++++++++++---
tests/virscsidata/0-0-0-0/type | 1 +
tests/virscsidata/1-0-0-0/type | 1 +
3 files changed, 131 insertions(+), 11 deletions(-)
create mode 100644 tests/virscsidata/0-0-0-0/type
create mode 100644 tests/virscsidata/1-0-0-0/type
diff --git a/src/util/virscsi.c b/src/util/virscsi.c
index b1f202eef1..3d68f829e4 100644
--- a/src/util/virscsi.c
+++ b/src/util/virscsi.c
@@ -47,6 +47,32 @@ struct _virUsedByInfo {
};
typedef struct _virUsedByInfo virUsedByInfo;
+
+/* Keep in sync with scsi/scsi_proto.h */
+typedef enum {
+ VIR_SCSI_DEVICE_TYPE_NONE = -1,
+ VIR_SCSI_DEVICE_TYPE_DISK = 0x00,
+ VIR_SCSI_DEVICE_TYPE_TAPE = 0x01,
+ VIR_SCSI_DEVICE_TYPE_PRINTER = 0x02,
+ VIR_SCSI_DEVICE_TYPE_PROCESSOR = 0x03,
+ VIR_SCSI_DEVICE_TYPE_WORM = 0x04,
+ VIR_SCSI_DEVICE_TYPE_ROM = 0x05,
+ VIR_SCSI_DEVICE_TYPE_SCANNER = 0x06,
+ VIR_SCSI_DEVICE_TYPE_MOD = 0x07,
+ VIR_SCSI_DEVICE_TYPE_MEDIUM_CHANGER = 0x08,
+ VIR_SCSI_DEVICE_TYPE_COMM = 0x09,
+ VIR_SCSI_DEVICE_TYPE_RAID = 0x0c,
+ VIR_SCSI_DEVICE_TYPE_ENCLOSURE = 0x0d,
+ VIR_SCSI_DEVICE_TYPE_RBC = 0x0e,
+ VIR_SCSI_DEVICE_TYPE_OSD = 0x11,
+ VIR_SCSI_DEVICE_TYPE_ZBC = 0x14,
+ VIR_SCSI_DEVICE_TYPE_WLUN = 0x1e,
+ VIR_SCSI_DEVICE_TYPE_NO_LUN = 0x7f,
+
+ VIR_SCSI_DEVICE_TYPE_LAST,
+} virSCSIDeviceType;
+
+
struct _virSCSIDevice {
unsigned int adapter;
unsigned int bus;
@@ -126,6 +152,78 @@ virSCSIDeviceGetSgName(const char *sysfs_prefix,
return NULL;
}
+
+static int
+virSCSIDeviceGetType(const char *prefix,
+ unsigned int adapter,
+ unsigned int bus,
+ unsigned int target,
+ unsigned long long unit,
+ virSCSIDeviceType *type)
+{
+ int intType;
+
+ if (virFileReadValueInt(&intType,
+ "%s/%d:%u:%u:%llu/type",
+ prefix, adapter, bus, target, unit) < 0)
+ return -1;
+
+ switch (intType) {
+ case VIR_SCSI_DEVICE_TYPE_DISK:
+ case VIR_SCSI_DEVICE_TYPE_TAPE:
+ case VIR_SCSI_DEVICE_TYPE_PRINTER:
+ case VIR_SCSI_DEVICE_TYPE_PROCESSOR:
+ case VIR_SCSI_DEVICE_TYPE_WORM:
+ case VIR_SCSI_DEVICE_TYPE_ROM:
+ case VIR_SCSI_DEVICE_TYPE_SCANNER:
+ case VIR_SCSI_DEVICE_TYPE_MOD:
+ case VIR_SCSI_DEVICE_TYPE_MEDIUM_CHANGER:
+ case VIR_SCSI_DEVICE_TYPE_COMM:
+ case VIR_SCSI_DEVICE_TYPE_RAID:
+ case VIR_SCSI_DEVICE_TYPE_ENCLOSURE:
+ case VIR_SCSI_DEVICE_TYPE_RBC:
+ case VIR_SCSI_DEVICE_TYPE_OSD:
+ case VIR_SCSI_DEVICE_TYPE_ZBC:
+ case VIR_SCSI_DEVICE_TYPE_WLUN:
+ case VIR_SCSI_DEVICE_TYPE_NO_LUN:
+ *type = intType;
+ break;
+
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unknown SCSI device type: %x"),
+ intType);
+ return -1;
+ }
+
+ return 0;
+}
+
+
+static char *
+virSCSIDeviceGetDevNameBlock(const char *prefix,
+ unsigned int adapter,
+ unsigned int bus,
+ unsigned int target,
+ unsigned long long unit)
+{
+ g_autoptr(DIR) dir = NULL;
+ struct dirent *entry;
+ g_autofree char *path = NULL;
+
+ path = g_strdup_printf("%s/%d:%u:%u:%llu/block",
+ prefix, adapter, bus, target, unit);
+
+ if (virDirOpen(&dir, path) < 0)
+ return NULL;
+
+ if (virDirRead(dir, &entry, path) > 0)
+ return g_strdup(entry->d_name);
+
+ return NULL;
+}
+
+
/* Returns device name (e.g. "sdc") on success, or NULL
* on failure.
*/
@@ -136,25 +234,45 @@ virSCSIDeviceGetDevName(const char *sysfs_prefix,
unsigned int target,
unsigned long long unit)
{
- g_autoptr(DIR) dir = NULL;
- struct dirent *entry;
- g_autofree char *path = NULL;
unsigned int adapter_id;
+ virSCSIDeviceType type;
const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SCSI_DEVICES;
if (virSCSIDeviceGetAdapterId(adapter, &adapter_id) < 0)
return NULL;
- path = g_strdup_printf("%s/%d:%u:%u:%llu/block", prefix, adapter_id, bus,
- target, unit);
-
- if (virDirOpen(&dir, path) < 0)
+ if (virSCSIDeviceGetType(prefix, adapter_id,
+ bus, target, unit, &type) < 0)
return NULL;
- if (virDirRead(dir, &entry, path) > 0)
- return g_strdup(entry->d_name);
-
- return NULL;
+ switch (type) {
+ case VIR_SCSI_DEVICE_TYPE_DISK:
+ return virSCSIDeviceGetDevNameBlock(prefix, adapter_id, bus, target, unit);
+
+ case VIR_SCSI_DEVICE_TYPE_TAPE:
+ case VIR_SCSI_DEVICE_TYPE_PRINTER:
+ case VIR_SCSI_DEVICE_TYPE_PROCESSOR:
+ case VIR_SCSI_DEVICE_TYPE_WORM:
+ case VIR_SCSI_DEVICE_TYPE_ROM:
+ case VIR_SCSI_DEVICE_TYPE_SCANNER:
+ case VIR_SCSI_DEVICE_TYPE_MOD:
+ case VIR_SCSI_DEVICE_TYPE_MEDIUM_CHANGER:
+ case VIR_SCSI_DEVICE_TYPE_COMM:
+ case VIR_SCSI_DEVICE_TYPE_RAID:
+ case VIR_SCSI_DEVICE_TYPE_ENCLOSURE:
+ case VIR_SCSI_DEVICE_TYPE_RBC:
+ case VIR_SCSI_DEVICE_TYPE_OSD:
+ case VIR_SCSI_DEVICE_TYPE_ZBC:
+ case VIR_SCSI_DEVICE_TYPE_WLUN:
+ case VIR_SCSI_DEVICE_TYPE_NO_LUN:
+ case VIR_SCSI_DEVICE_TYPE_NONE:
+ case VIR_SCSI_DEVICE_TYPE_LAST:
+ default:
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unsupported SCSI device type: %x"),
+ type);
+ return NULL;
+ }
}
virSCSIDevice *
diff --git a/tests/virscsidata/0-0-0-0/type b/tests/virscsidata/0-0-0-0/type
new file mode 100644
index 0000000000..573541ac97
--- /dev/null
+++ b/tests/virscsidata/0-0-0-0/type
@@ -0,0 +1 @@
+0
diff --git a/tests/virscsidata/1-0-0-0/type b/tests/virscsidata/1-0-0-0/type
new file mode 100644
index 0000000000..573541ac97
--- /dev/null
+++ b/tests/virscsidata/1-0-0-0/type
@@ -0,0 +1 @@
+0
--
2.31.1

View File

@ -0,0 +1,267 @@
From 457743256ed748642b58ab4edb7166f63fc3c8de Mon Sep 17 00:00:00 2001
Message-Id: <457743256ed748642b58ab4edb7166f63fc3c8de@dist-git>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Fri, 6 Mar 2020 15:52:23 +0100
Subject: [PATCH] RHEL: virscsi: Introduce and use
virSCSIDeviceGetUnprivSGIOSysfsPath()
When constructing a path to the 'unpriv_sgio' file of given SCSI
device we don't need to go through /dev/* and major() + minor()
path. The generated path points to
/sys/dev/block/MAJ:MIN/queue/unpriv_sgio which is wrong if the
SCSI device in question is not a block device. We can generate a
different path: /sys/bus/scsi/devices/X:X:X:X/unpriv_sgio where
the file is directly accessible regardless of the SCSI device
type.
https://bugzilla.redhat.com/show_bug.cgi?id=1808390
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Message-Id: <20200306145226.1610708-4-abologna@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
src/libvirt_private.syms | 1 +
src/qemu/qemu_conf.c | 29 ++++++++++++++++++-----------
src/util/virscsi.c | 19 +++++++++++++++++++
src/util/virscsi.h | 5 +++++
src/util/virutil.c | 24 ++++++------------------
src/util/virutil.h | 2 --
6 files changed, 49 insertions(+), 31 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 9f761c2c00..2dcf4875bb 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -3144,6 +3144,7 @@ virSCSIDeviceGetSgName;
virSCSIDeviceGetShareable;
virSCSIDeviceGetTarget;
virSCSIDeviceGetUnit;
+virSCSIDeviceGetUnprivSGIOSysfsPath;
virSCSIDeviceIsAvailable;
virSCSIDeviceListAdd;
virSCSIDeviceListCount;
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 2beef89cd1..90ff7f56f0 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1500,7 +1500,7 @@ qemuCheckUnprivSGIO(GHashTable *sharedDevices,
if (!(virHashLookup(sharedDevices, key)))
return 0;
- if (virGetDeviceUnprivSGIO(device_path, NULL, &val) < 0)
+ if (virGetDeviceUnprivSGIO(sysfs_path, &val) < 0)
return -1;
/* Error message on failure needs to be handled in caller
@@ -1852,39 +1852,46 @@ qemuSetUnprivSGIO(virDomainDeviceDef *dev)
virDomainDiskDef *disk = NULL;
virDomainHostdevDef *hostdev = NULL;
g_autofree char *sysfs_path = NULL;
- g_autofree char *hostdev_path = NULL;
- const char *path = NULL;
int val = 0;
/* "sgio" is only valid for block disk; cdrom
* and floopy disk can have empty source.
*/
if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
+ const char *path;
+
disk = dev->data.disk;
+ path = virDomainDiskGetSource(disk);
if (disk->device != VIR_DOMAIN_DISK_DEVICE_LUN ||
!virStorageSourceIsBlockLocal(disk->src))
return 0;
- path = virDomainDiskGetSource(disk);
+ if (!(sysfs_path = virGetUnprivSGIOSysfsPath(path, NULL)))
+ return -1;
+
} else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
+ virDomainHostdevSubsysSCSI *scsisrc;
+ virDomainHostdevSubsysSCSIHost *scsihostsrc;
+
hostdev = dev->data.hostdev;
+ scsisrc = &hostdev->source.subsys.u.scsi;
+ scsihostsrc = &scsisrc->u.host;
if (hostdev->source.subsys.u.scsi.protocol ==
VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)
return 0;
- if (!(hostdev_path = qemuGetHostdevPath(hostdev)))
+ if (!(sysfs_path = virSCSIDeviceGetUnprivSGIOSysfsPath(NULL,
+ scsihostsrc->adapter,
+ scsihostsrc->bus,
+ scsihostsrc->target,
+ scsihostsrc->unit)))
return -1;
-
- path = hostdev_path;
} else {
return 0;
}
- if (!(sysfs_path = virGetUnprivSGIOSysfsPath(path, NULL)))
- return -1;
-
/* By default, filter the SG_IO commands, i.e. set unpriv_sgio to 0. */
if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
if (disk->sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED)
@@ -1902,7 +1909,7 @@ qemuSetUnprivSGIO(virDomainDeviceDef *dev)
* virSetDeviceUnprivSGIO, to report an error for unsupported unpriv_sgio.
*/
if ((virFileExists(sysfs_path) || val == 1) &&
- virSetDeviceUnprivSGIO(path, NULL, val) < 0)
+ virSetDeviceUnprivSGIO(sysfs_path, val) < 0)
return -1;
return 0;
diff --git a/src/util/virscsi.c b/src/util/virscsi.c
index d6c10c0667..7a8e6b3b23 100644
--- a/src/util/virscsi.c
+++ b/src/util/virscsi.c
@@ -302,6 +302,25 @@ virSCSIDeviceGetDevName(const char *sysfs_prefix,
}
}
+
+char *
+virSCSIDeviceGetUnprivSGIOSysfsPath(const char *sysfs_prefix,
+ const char *adapter,
+ unsigned int bus,
+ unsigned int target,
+ unsigned long long unit)
+{
+ unsigned int adapter_id;
+ const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SCSI_DEVICES;
+
+ if (virSCSIDeviceGetAdapterId(adapter, &adapter_id) < 0)
+ return NULL;
+
+ return g_strdup_printf("%s/%d:%u:%u:%llu/unpriv_sgio",
+ prefix, adapter_id, bus, target, unit);
+}
+
+
virSCSIDevice *
virSCSIDeviceNew(const char *sysfs_prefix,
const char *adapter,
diff --git a/src/util/virscsi.h b/src/util/virscsi.h
index 65ad15ed76..5721985939 100644
--- a/src/util/virscsi.h
+++ b/src/util/virscsi.h
@@ -40,6 +40,11 @@ char *virSCSIDeviceGetDevName(const char *sysfs_prefix,
unsigned int bus,
unsigned int target,
unsigned long long unit);
+char *virSCSIDeviceGetUnprivSGIOSysfsPath(const char *sysfs_prefix,
+ const char *adapter,
+ unsigned int bus,
+ unsigned int target,
+ unsigned long long unit);
virSCSIDevice *virSCSIDeviceNew(const char *sysfs_prefix,
const char *adapter,
diff --git a/src/util/virutil.c b/src/util/virutil.c
index 3f49a469e5..970b9f1fec 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -1387,18 +1387,13 @@ virGetUnprivSGIOSysfsPath(const char *path,
int
virSetDeviceUnprivSGIO(const char *path,
- const char *sysfs_dir,
int unpriv_sgio)
{
- char *sysfs_path = NULL;
char *val = NULL;
int ret = -1;
int rc;
- if (!(sysfs_path = virGetUnprivSGIOSysfsPath(path, sysfs_dir)))
- return -1;
-
- if (!virFileExists(sysfs_path)) {
+ if (!virFileExists(path)) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("unpriv_sgio is not supported by this kernel"));
goto cleanup;
@@ -1406,38 +1401,32 @@ virSetDeviceUnprivSGIO(const char *path,
val = g_strdup_printf("%d", unpriv_sgio);
- if ((rc = virFileWriteStr(sysfs_path, val, 0)) < 0) {
- virReportSystemError(-rc, _("failed to set %s"), sysfs_path);
+ if ((rc = virFileWriteStr(path, val, 0)) < 0) {
+ virReportSystemError(-rc, _("failed to set %s"), path);
goto cleanup;
}
ret = 0;
cleanup:
- VIR_FREE(sysfs_path);
VIR_FREE(val);
return ret;
}
int
virGetDeviceUnprivSGIO(const char *path,
- const char *sysfs_dir,
int *unpriv_sgio)
{
- char *sysfs_path = NULL;
char *buf = NULL;
char *tmp = NULL;
int ret = -1;
- if (!(sysfs_path = virGetUnprivSGIOSysfsPath(path, sysfs_dir)))
- return -1;
-
- if (!virFileExists(sysfs_path)) {
+ if (!virFileExists(path)) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("unpriv_sgio is not supported by this kernel"));
goto cleanup;
}
- if (virFileReadAll(sysfs_path, 1024, &buf) < 0)
+ if (virFileReadAll(path, 1024, &buf) < 0)
goto cleanup;
if ((tmp = strchr(buf, '\n')))
@@ -1445,13 +1434,12 @@ virGetDeviceUnprivSGIO(const char *path,
if (virStrToLong_i(buf, NULL, 10, unpriv_sgio) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("failed to parse value of %s"), sysfs_path);
+ _("failed to parse value of %s"), path);
goto cleanup;
}
ret = 0;
cleanup:
- VIR_FREE(sysfs_path);
VIR_FREE(buf);
return ret;
}
diff --git a/src/util/virutil.h b/src/util/virutil.h
index 854b494890..da267c6446 100644
--- a/src/util/virutil.h
+++ b/src/util/virutil.h
@@ -120,10 +120,8 @@ int virGetDeviceID(const char *path,
int *maj,
int *min) G_GNUC_NO_INLINE;
int virSetDeviceUnprivSGIO(const char *path,
- const char *sysfs_dir,
int unpriv_sgio);
int virGetDeviceUnprivSGIO(const char *path,
- const char *sysfs_dir,
int *unpriv_sgio);
char *virGetUnprivSGIOSysfsPath(const char *path,
const char *sysfs_dir);
--
2.31.1

View File

@ -0,0 +1,201 @@
From e089400f1343ef4c4e735dbcc5c966b50fdab70f Mon Sep 17 00:00:00 2001
Message-Id: <e089400f1343ef4c4e735dbcc5c966b50fdab70f@dist-git>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Fri, 6 Mar 2020 15:52:22 +0100
Subject: [PATCH] RHEL: virscsi: Support TAPEs in virSCSIDeviceGetDevName()
If the SCSI device we want to get /dev node name for is TAPE
device we need to look at 'tape' symlink in the sysfs dir
corresponding to the device.
https://bugzilla.redhat.com/show_bug.cgi?id=1808390
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Message-Id: <20200306145226.1610708-3-abologna@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
src/util/virscsi.c | 27 +++++++++++++++
tests/virscsidata/2-0-0-0/model | 1 +
tests/virscsidata/2-0-0-0/scsi_tape/st0/dev | 1 +
tests/virscsidata/2-0-0-0/sg3/dev | 1 +
tests/virscsidata/2-0-0-0/tape | 1 +
tests/virscsidata/2-0-0-0/type | 1 +
tests/virscsidata/2-0-0-0/vendor | 1 +
tests/virscsidata/sg3 | 0
tests/virscsitest.c | 38 ++++++++++++++++++---
9 files changed, 66 insertions(+), 5 deletions(-)
create mode 100644 tests/virscsidata/2-0-0-0/model
create mode 100644 tests/virscsidata/2-0-0-0/scsi_tape/st0/dev
create mode 100644 tests/virscsidata/2-0-0-0/sg3/dev
create mode 120000 tests/virscsidata/2-0-0-0/tape
create mode 100644 tests/virscsidata/2-0-0-0/type
create mode 100644 tests/virscsidata/2-0-0-0/vendor
create mode 100644 tests/virscsidata/sg3
diff --git a/src/util/virscsi.c b/src/util/virscsi.c
index 3d68f829e4..d6c10c0667 100644
--- a/src/util/virscsi.c
+++ b/src/util/virscsi.c
@@ -224,6 +224,31 @@ virSCSIDeviceGetDevNameBlock(const char *prefix,
}
+static char *
+virSCSIDeviceGetDevNameTape(const char *prefix,
+ unsigned int adapter,
+ unsigned int bus,
+ unsigned int target,
+ unsigned long long unit)
+{
+ g_autofree char *path = NULL;
+ g_autofree char *resolvedPath = NULL;
+ g_autoptr(GError) err = NULL;
+
+ path = g_strdup_printf("%s/%d:%u:%u:%llu/tape",
+ prefix, adapter, bus, target, unit);
+
+ if (!(resolvedPath = g_file_read_link(path, &err))) {
+ virReportError(VIR_ERR_SYSTEM_ERROR,
+ _("Unable to read link: %s"),
+ err->message);
+ return NULL;
+ }
+
+ return g_path_get_basename(resolvedPath);
+}
+
+
/* Returns device name (e.g. "sdc") on success, or NULL
* on failure.
*/
@@ -250,6 +275,8 @@ virSCSIDeviceGetDevName(const char *sysfs_prefix,
return virSCSIDeviceGetDevNameBlock(prefix, adapter_id, bus, target, unit);
case VIR_SCSI_DEVICE_TYPE_TAPE:
+ return virSCSIDeviceGetDevNameTape(prefix, adapter_id, bus, target, unit);
+
case VIR_SCSI_DEVICE_TYPE_PRINTER:
case VIR_SCSI_DEVICE_TYPE_PROCESSOR:
case VIR_SCSI_DEVICE_TYPE_WORM:
diff --git a/tests/virscsidata/2-0-0-0/model b/tests/virscsidata/2-0-0-0/model
new file mode 100644
index 0000000000..d2ab4715c3
--- /dev/null
+++ b/tests/virscsidata/2-0-0-0/model
@@ -0,0 +1 @@
+scsi_debug
diff --git a/tests/virscsidata/2-0-0-0/scsi_tape/st0/dev b/tests/virscsidata/2-0-0-0/scsi_tape/st0/dev
new file mode 100644
index 0000000000..3dd777e840
--- /dev/null
+++ b/tests/virscsidata/2-0-0-0/scsi_tape/st0/dev
@@ -0,0 +1 @@
+9:0
diff --git a/tests/virscsidata/2-0-0-0/sg3/dev b/tests/virscsidata/2-0-0-0/sg3/dev
new file mode 100644
index 0000000000..b369a59b3e
--- /dev/null
+++ b/tests/virscsidata/2-0-0-0/sg3/dev
@@ -0,0 +1 @@
+21:3
diff --git a/tests/virscsidata/2-0-0-0/tape b/tests/virscsidata/2-0-0-0/tape
new file mode 120000
index 0000000000..6ca7f77539
--- /dev/null
+++ b/tests/virscsidata/2-0-0-0/tape
@@ -0,0 +1 @@
+scsi_tape/st0
\ No newline at end of file
diff --git a/tests/virscsidata/2-0-0-0/type b/tests/virscsidata/2-0-0-0/type
new file mode 100644
index 0000000000..d00491fd7e
--- /dev/null
+++ b/tests/virscsidata/2-0-0-0/type
@@ -0,0 +1 @@
+1
diff --git a/tests/virscsidata/2-0-0-0/vendor b/tests/virscsidata/2-0-0-0/vendor
new file mode 100644
index 0000000000..9b075671ea
--- /dev/null
+++ b/tests/virscsidata/2-0-0-0/vendor
@@ -0,0 +1 @@
+Linux
diff --git a/tests/virscsidata/sg3 b/tests/virscsidata/sg3
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tests/virscsitest.c b/tests/virscsitest.c
index 84b6f15ec6..a897de918c 100644
--- a/tests/virscsitest.c
+++ b/tests/virscsitest.c
@@ -33,18 +33,34 @@ VIR_LOG_INIT("tests.scsitest");
static char *virscsi_prefix;
+typedef struct {
+ const char *adapter;
+ unsigned int bus;
+ unsigned int target;
+ unsigned int unit;
+ const char *expectedName;
+} testGetDevNameData;
+
static int
-test1(const void *data G_GNUC_UNUSED)
+testGetDevName(const void *opaque)
{
+ const testGetDevNameData *data = opaque;
char *name = NULL;
int ret = -1;
if (!(name = virSCSIDeviceGetDevName(virscsi_prefix,
- "scsi_host1", 0, 0, 0)))
+ data->adapter,
+ data->bus,
+ data->target,
+ data->unit)))
return -1;
- if (STRNEQ(name, "sdh"))
+ if (STRNEQ(name, data->expectedName)) {
+ fprintf(stderr,
+ "SCSI dev name mismatch, expected %s got %s",
+ data->expectedName, name);
goto cleanup;
+ }
ret = 0;
cleanup:
@@ -213,15 +229,27 @@ mymain(void)
CREATE_SYMLINK("0-0-0-0", "0:0:0:0");
CREATE_SYMLINK("1-0-0-0", "1:0:0:0");
+ CREATE_SYMLINK("2-0-0-0", "2:0:0:0");
CREATE_SYMLINK("sg0", "sg0");
+ CREATE_SYMLINK("sg3", "sg3");
CREATE_SYMLINK("sg8", "sg8");
VIR_FREE(virscsi_prefix);
virscsi_prefix = g_strdup(tmpdir);
- if (virTestRun("test1", test1, NULL) < 0)
- ret = -1;
+#define TEST_GET_DEV_NAME(adapter, bus, target, unit, expectedName) \
+ do { \
+ testGetDevNameData data = {adapter, bus, target, unit, expectedName}; \
+ if (virTestRun("test getDevname " expectedName, \
+ testGetDevName, &data) < 0) \
+ ret = -1; \
+ } while (0)
+
+ TEST_GET_DEV_NAME("scsi_host0", 0, 0, 0, "sda");
+ TEST_GET_DEV_NAME("scsi_host1", 0, 0, 0, "sdh");
+ TEST_GET_DEV_NAME("scsi_host2", 0, 0, 0, "st0");
+
if (virTestRun("test2", test2, NULL) < 0)
ret = -1;
--
2.31.1

View File

@ -0,0 +1,37 @@
From c37b04bc3d636d8d96f9e40075336ff5166d5585 Mon Sep 17 00:00:00 2001
Message-Id: <c37b04bc3d636d8d96f9e40075336ff5166d5585@dist-git>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Fri, 6 Mar 2020 15:52:24 +0100
Subject: [PATCH] RHEL: virutil: Accept non-block devices in virGetDeviceID()
If a caller wants to learn major or minor number for a device,
let them. There's no need to check if the device is a block
device here.
https://bugzilla.redhat.com/show_bug.cgi?id=1808390
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Message-Id: <20200306145226.1610708-5-abologna@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
src/util/virutil.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/src/util/virutil.c b/src/util/virutil.c
index 970b9f1fec..135e1e5943 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -1343,9 +1343,6 @@ virGetDeviceID(const char *path, int *maj, int *min)
if (stat(path, &sb) < 0)
return -errno;
- if (!S_ISBLK(sb.st_mode))
- return -EINVAL;
-
if (maj)
*maj = major(sb.st_rdev);
if (min)
--
2.31.1

View File

@ -17,7 +17,7 @@
%define _vpath_builddir %{_target_platform}
%endif
%define arches_qemu_kvm %{ix86} x86_64 %{power64} %{arm} aarch64 s390x riscv64
%define arches_qemu_kvm %{ix86} x86_64 %{power64} %{arm} aarch64 s390x
%if 0%{?rhel}
%if 0%{?rhel} <= 8
%define arches_qemu_kvm x86_64 %{power64} aarch64 s390x
@ -222,8 +222,8 @@
Summary: Library providing a simple virtualization API
Name: libvirt
Version: 7.0.0
Release: 6%{?dist}
Version: 7.3.0
Release: 1%{?dist}%{?extra_release}
License: LGPLv2+
URL: https://libvirt.org/
@ -231,8 +231,16 @@ URL: https://libvirt.org/
%define mainturl stable_updates/
%endif
Source: https://libvirt.org/sources/%{?mainturl}libvirt-%{version}.tar.xz
Source1: symlinks
Patch0001: 0001-build-support-explicitly-disabling-netcf.patch
Patch1: libvirt-RHEL-Fix-virConnectGetMaxVcpus-output.patch
Patch2: libvirt-RHEL-qemu-Add-ability-to-set-sgio-values-for-hostdev.patch
Patch3: libvirt-RHEL-qemu-Add-check-for-unpriv-sgio-for-SCSI-generic-host-device.patch
Patch4: libvirt-RHEL-virscsi-Check-device-type-before-getting-it-s-dev-node-name.patch
Patch5: libvirt-RHEL-virscsi-Support-TAPEs-in-virSCSIDeviceGetDevName.patch
Patch6: libvirt-RHEL-virscsi-Introduce-and-use-virSCSIDeviceGetUnprivSGIOSysfsPath.patch
Patch7: libvirt-RHEL-virutil-Accept-non-block-devices-in-virGetDeviceID.patch
Patch8: libvirt-RHEL-Enable-usage-of-x-blockdev-reopen.patch
Requires: libvirt-daemon = %{version}-%{release}
Requires: libvirt-daemon-config-network = %{version}-%{release}
@ -264,7 +272,6 @@ Requires: libvirt-libs = %{version}-%{release}
# All build-time requirements. Run-time requirements are
# listed against each sub-RPM
BuildRequires: gettext-devel
%if 0%{?rhel} == 7
BuildRequires: python36-docutils
%else
@ -273,7 +280,6 @@ BuildRequires: python3-docutils
BuildRequires: gcc
BuildRequires: meson >= 0.54.0
BuildRequires: ninja-build
BuildRequires: make
BuildRequires: git
%if 0%{?fedora} || 0%{?rhel} > 7
BuildRequires: perl-interpreter
@ -285,7 +291,7 @@ BuildRequires: systemd-units
%if %{with_libxl}
BuildRequires: xen-devel
%endif
BuildRequires: glib2-devel >= 2.48
BuildRequires: glib2-devel >= 2.56
BuildRequires: libxml2-devel
BuildRequires: libxslt
BuildRequires: readline-devel
@ -468,6 +474,13 @@ Requires: numad
Requires: dbus
# For uid creation during pre
Requires(pre): shadow-utils
# Needed by /usr/libexec/libvirt-guests.sh script.
Requires: gettext
# Ensure smooth upgrades
Obsoletes: libvirt-admin < 7.3.0
Provides: libvirt-admin
Obsoletes: libvirt-bash-completion < 7.3.0
%description daemon
Server side daemon required to manage the virtualization capabilities
@ -905,11 +918,11 @@ capabilities of VirtualBox
%package client
Summary: Client side utilities of the libvirt library
Requires: %{name}-libs = %{version}-%{release}
# Needed by /usr/libexec/libvirt-guests.sh script.
Requires: gettext
# Needed by virt-pki-validate script.
Requires: gnutls-utils
Requires: %{name}-bash-completion = %{version}-%{release}
# Ensure smooth upgrades
Obsoletes: libvirt-bash-completion < 7.3.0
%description client
The client binaries needed to access the virtualization
@ -926,20 +939,6 @@ Requires: cyrus-sasl-gssapi
%description libs
Shared libraries for accessing the libvirt daemon.
%package admin
Summary: Set of tools to control libvirt daemon
Requires: %{name}-libs = %{version}-%{release}
Requires: %{name}-bash-completion = %{version}-%{release}
%description admin
The client side utilities to control the libvirt daemon.
%package bash-completion
Summary: Bash completion script
%description bash-completion
Bash completion script stub.
%if %{with_wireshark}
%package wireshark
Summary: Wireshark dissector plugin for libvirt RPC transactions
@ -993,7 +992,24 @@ Libvirt plugin for NSS for translating domain names into IP addresses.
%prep
%autosetup -S git_am
%autosetup -S git_am -N
# "make dist" replaces all symlinks with a copy of the linked files;
# we need to replace all of them with the original symlinks
echo "Restoring symlinks"
while read lnk target; do
if [ -e $lnk ]; then
rm -rf $lnk
ln -s $target $lnk
fi
done <%{_sourcedir}/symlinks || exit 1
git add .
git commit -q -a --allow-empty --author 'rpm-build <rpm-build>' -m symlinks
git config gc.auto 0
%autopatch
%build
@ -1335,6 +1351,7 @@ exit 0
%systemd_post libvirtd.socket libvirtd-ro.socket libvirtd-admin.socket
%systemd_post libvirtd-tcp.socket libvirtd-tls.socket
%systemd_post libvirtd.service
%systemd_post libvirt-guests.service
# request daemon restart in posttrans
mkdir -p %{_localstatedir}/lib/rpm-state/libvirt || :
@ -1346,6 +1363,7 @@ touch %{_localstatedir}/lib/rpm-state/libvirt/restart || :
%systemd_preun libvirtd.socket libvirtd-ro.socket libvirtd-admin.socket
%systemd_preun virtlogd.socket virtlogd-admin.socket virtlogd.service
%systemd_preun virtlockd.socket virtlockd-admin.socket virtlockd.service
%systemd_preun libvirt-guests.service
%postun daemon
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
@ -1353,6 +1371,7 @@ if [ $1 -ge 1 ] ; then
/bin/systemctl reload-or-try-restart virtlockd.service >/dev/null 2>&1 || :
/bin/systemctl reload-or-try-restart virtlogd.service >/dev/null 2>&1 || :
fi
%systemd_postun libvirt-guests.service
# In upgrade scenario we must explicitly enable virtlockd/virtlogd
# sockets, if libvirtd is already enabled and start them if
@ -1497,16 +1516,6 @@ fi
exit 0
%endif
%preun client
%systemd_preun libvirt-guests.service
%post client
%systemd_post libvirt-guests.service
%postun client
%systemd_postun libvirt-guests.service
%if %{with_lxc}
%pre login-shell
getent group virtlogin >/dev/null || groupadd -r virtlogin
@ -1542,6 +1551,7 @@ exit 0
%{_unitdir}/virtlockd.service
%{_unitdir}/virtlockd.socket
%{_unitdir}/virtlockd-admin.socket
%{_unitdir}/libvirt-guests.service
%config(noreplace) %{_sysconfdir}/sysconfig/libvirtd
%config(noreplace) %{_sysconfdir}/sysconfig/virtproxyd
%config(noreplace) %{_sysconfdir}/sysconfig/virtlogd
@ -1551,6 +1561,7 @@ exit 0
%config(noreplace) %{_sysconfdir}/libvirt/virtlogd.conf
%config(noreplace) %{_sysconfdir}/libvirt/virtlockd.conf
%config(noreplace) %{_sysconfdir}/sasl2/libvirt.conf
%config(noreplace) %{_sysconfdir}/sysconfig/libvirt-guests
%config(noreplace) %{_prefix}/lib/sysctl.d/60-libvirtd.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/libvirtd
@ -1596,12 +1607,20 @@ exit 0
%attr(0755, root, root) %{_sbindir}/virtproxyd
%attr(0755, root, root) %{_sbindir}/virtlogd
%attr(0755, root, root) %{_sbindir}/virtlockd
%attr(0755, root, root) %{_libexecdir}/libvirt-guests.sh
%{_mandir}/man1/virt-admin.1*
%{_mandir}/man1/virt-host-validate.1*
%{_mandir}/man8/libvirtd.8*
%{_mandir}/man8/virtlogd.8*
%{_mandir}/man8/virtlockd.8*
%{_mandir}/man8/virtproxyd.8*
%{_mandir}/man7/virkey*.7*
%{_bindir}/virt-host-validate
%{_bindir}/virt-admin
%{_datadir}/bash-completion/completions/virt-admin
%files daemon-config-network
%dir %{_datadir}/libvirt/networks/
%{_datadir}/libvirt/networks/default.xml
@ -1624,6 +1643,7 @@ exit 0
%{_unitdir}/virtinterfaced-admin.socket
%attr(0755, root, root) %{_sbindir}/virtinterfaced
%{_libdir}/%{name}/connection-driver/libvirt_driver_interface.so
%{_mandir}/man8/virtinterfaced.8*
%files daemon-driver-network
%config(noreplace) %{_sysconfdir}/sysconfig/virtnetworkd
@ -1643,6 +1663,7 @@ exit 0
%dir %attr(0755, root, root) %{_localstatedir}/lib/libvirt/dnsmasq/
%attr(0755, root, root) %{_libexecdir}/libvirt_leaseshelper
%{_libdir}/%{name}/connection-driver/libvirt_driver_network.so
%{_mandir}/man8/virtnetworkd.8*
%if %{with_firewalld_zone}
%{_prefix}/lib/firewalld/zones/libvirt.xml
@ -1659,6 +1680,7 @@ exit 0
%{_unitdir}/virtnodedevd-admin.socket
%attr(0755, root, root) %{_sbindir}/virtnodedevd
%{_libdir}/%{name}/connection-driver/libvirt_driver_nodedev.so
%{_mandir}/man8/virtnodedevd.8*
%files daemon-driver-nwfilter
%config(noreplace) %{_sysconfdir}/sysconfig/virtnwfilterd
@ -1673,6 +1695,7 @@ exit 0
%dir %attr(0700, root, root) %{_sysconfdir}/libvirt/nwfilter/
%ghost %dir %{_rundir}/libvirt/network/
%{_libdir}/%{name}/connection-driver/libvirt_driver_nwfilter.so
%{_mandir}/man8/virtnwfilterd.8*
%files daemon-driver-secret
%config(noreplace) %{_sysconfdir}/sysconfig/virtsecretd
@ -1685,6 +1708,7 @@ exit 0
%{_unitdir}/virtsecretd-admin.socket
%attr(0755, root, root) %{_sbindir}/virtsecretd
%{_libdir}/%{name}/connection-driver/libvirt_driver_secret.so
%{_mandir}/man8/virtsecretd.8*
%files daemon-driver-storage
@ -1702,6 +1726,7 @@ exit 0
%{_libdir}/%{name}/connection-driver/libvirt_driver_storage.so
%{_libdir}/%{name}/storage-backend/libvirt_storage_backend_fs.so
%{_libdir}/%{name}/storage-file/libvirt_storage_file_fs.so
%{_mandir}/man8/virtstoraged.8*
%files daemon-driver-storage-disk
%{_libdir}/%{name}/storage-backend/libvirt_storage_backend_disk.so
@ -1770,6 +1795,7 @@ exit 0
%dir %attr(0730, tss, tss) %{_localstatedir}/log/swtpm/libvirt/qemu/
%{_bindir}/virt-qemu-run
%{_mandir}/man1/virt-qemu-run.1*
%{_mandir}/man8/virtqemud.8*
%endif
%if %{with_lxc}
@ -1792,6 +1818,7 @@ exit 0
%{_datadir}/augeas/lenses/tests/test_libvirtd_lxc.aug
%attr(0755, root, root) %{_libexecdir}/libvirt_lxc
%{_libdir}/%{name}/connection-driver/libvirt_driver_lxc.so
%{_mandir}/man8/virtlxcd.8*
%endif
%if %{with_libxl}
@ -1814,6 +1841,7 @@ exit 0
%ghost %dir %{_rundir}/libvirt/libxl/
%dir %attr(0700, root, root) %{_localstatedir}/lib/libvirt/libxl/
%{_libdir}/%{name}/connection-driver/libvirt_driver_libxl.so
%{_mandir}/man8/virtxend.8*
%endif
%if %{with_vbox}
@ -1828,6 +1856,7 @@ exit 0
%{_unitdir}/virtvboxd-admin.socket
%attr(0755, root, root) %{_sbindir}/virtvboxd
%{_libdir}/%{name}/connection-driver/libvirt_driver_vbox.so
%{_mandir}/man8/virtvboxd.8*
%endif
%if %{with_qemu_tcg}
@ -1871,25 +1900,12 @@ exit 0
%{_mandir}/man1/virsh.1*
%{_mandir}/man1/virt-xml-validate.1*
%{_mandir}/man1/virt-pki-validate.1*
%{_mandir}/man1/virt-host-validate.1*
%{_bindir}/virsh
%{_bindir}/virt-xml-validate
%{_bindir}/virt-pki-validate
%{_bindir}/virt-host-validate
%{_datadir}/systemtap/tapset/libvirt_probes*.stp
%{_datadir}/systemtap/tapset/libvirt_functions.stp
%if %{with_qemu}
%{_datadir}/systemtap/tapset/libvirt_qemu_probes*.stp
%endif
%{_datadir}/bash-completion/completions/virsh
%{_unitdir}/libvirt-guests.service
%config(noreplace) %{_sysconfdir}/sysconfig/libvirt-guests
%attr(0755, root, root) %{_libexecdir}/libvirt-guests.sh
%files libs -f %{name}.lang
%license COPYING COPYING.LESSER
%config(noreplace) %{_sysconfdir}/libvirt/libvirt.conf
@ -1902,20 +1918,18 @@ exit 0
%dir %{_datadir}/libvirt/schemas/
%dir %attr(0755, root, root) %{_localstatedir}/lib/libvirt/
%{_datadir}/systemtap/tapset/libvirt_probes*.stp
%{_datadir}/systemtap/tapset/libvirt_functions.stp
%if %{with_qemu}
%{_datadir}/systemtap/tapset/libvirt_qemu_probes*.stp
%endif
%{_datadir}/libvirt/schemas/*.rng
%{_datadir}/libvirt/cpu_map/*.xml
%{_datadir}/libvirt/test-screenshot.png
%files admin
%{_mandir}/man1/virt-admin.1*
%{_bindir}/virt-admin
%{_datadir}/bash-completion/completions/virt-admin
%files bash-completion
%{_datadir}/bash-completion/completions/vsh
%if %{with_wireshark}
%files wireshark
%{wireshark_plugindir}/libvirt.so
@ -1970,6 +1984,16 @@ exit 0
%changelog
* Mon May 24 2021 Jiri Denemark <jdenemar@redhat.com> - 7.3.0-1
- Rebased to libvirt-7.3.0 (rhbz#1950948)
- The rebase also fixes the following bugs:
rhbz#1898526, rhbz#1910617, rhbz#1910618, rhbz#1943392, rhbz#1946918
rhbz#1947718, rhbz#1947720, rhbz#1947824, rhbz#1949342, rhbz#1950228
rhbz#1950301, rhbz#1950601, rhbz#1950948, rhbz#1953939, rhbz#1958302
rhbz#1962053
- RHEL: Enable usage of x-blockdev-reopen (rhbz#1953939)
- RHEL: Add gating.yaml for RHEL9 (rhbz#1950601)
* Thu Apr 22 2021 Jiri Denemark <jdenemar@redhat.com> - 7.0.0-6
- spec: Do not build qemu driver for Power on RHEL-9 (rhbz#1946529)

View File

@ -1 +1 @@
SHA512 (libvirt-7.0.0.tar.xz) = dd6db5ec4971cf4c6059795fd81d5a3a889b10740e34c3c92271eda1c683c99df2c8f923398065d8a7c4f987a20eb1da617d5297ba8ea5a31f154412af50c343
SHA512 (libvirt-7.3.0.tar.xz) = e039d5cc000c0f29ead4faddf154852ee8d8b5943e940b717eabb33cc9990d3f257a942b05a661bf6c36df5b5763c31df3f8b5a0fc21e8111a81c57da42d903e

1058
symlinks Normal file

File diff suppressed because it is too large Load Diff