[libvirt] [PATCH 1/1] util/virhostdev: consolidate duplicated KVM support code
by Daniel Henrique Barboza
tests/virhostdevtest.c implements a function called
'virHostdevHostSupportsPassthroughKVM', that is equal to
'qemuHostdevHostSupportsPassthroughLegacy' that is declared
inside qemu/qemu_hostdev.c.
This patch removes the duplicated code from both files and
and puts it inside util/virhostdev.c, under the name
virHostdev...KVM, which represents what the code does better
than using 'Legacy'.
Based-on-work-of: Shivaprasad G Bhat <sbhat(a)linux.vnet.ibm.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413(a)gmail.com>
---
src/libvirt_private.syms | 1 +
src/qemu/qemu_capabilities.c | 2 +-
src/qemu/qemu_driver.c | 6 +++---
src/qemu/qemu_hostdev.c | 34 +---------------------------------
src/qemu/qemu_hostdev.h | 1 -
src/util/virhostdev.c | 31 +++++++++++++++++++++++++++++++
src/util/virhostdev.h | 1 +
tests/virhostdevtest.c | 31 -------------------------------
8 files changed, 38 insertions(+), 69 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index a03cf0b645..a6747684ea 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2044,6 +2044,7 @@ virHostCPUStatsAssign;
# util/virhostdev.h
virHostdevFindUSBDevice;
+virHostdevHostSupportsPassthroughKVM;
virHostdevIsMdevDevice;
virHostdevIsSCSIDevice;
virHostdevManagerGetDefault;
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index a0b2ca73fb..515db0112f 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -5152,7 +5152,7 @@ static int
virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCapsPtr qemuCaps,
virDomainCapsDeviceHostdevPtr hostdev)
{
- bool supportsPassthroughKVM = qemuHostdevHostSupportsPassthroughLegacy();
+ bool supportsPassthroughKVM = virHostdevHostSupportsPassthroughKVM();
bool supportsPassthroughVFIO = qemuHostdevHostSupportsPassthroughVFIO();
hostdev->supported = VIR_TRISTATE_BOOL_YES;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b2ac737d1f..c02482337a 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13283,7 +13283,7 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev,
int ret = -1;
virNodeDeviceDefPtr def = NULL;
char *xml = NULL;
- bool legacy = qemuHostdevHostSupportsPassthroughLegacy();
+ bool kvm = virHostdevHostSupportsPassthroughKVM();
bool vfio = qemuHostdevHostSupportsPassthroughVFIO();
virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
@@ -13310,7 +13310,7 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev,
if (!driverName) {
if (vfio) {
driverName = "vfio";
- } else if (legacy) {
+ } else if (kvm) {
driverName = "kvm";
} else {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
@@ -13329,7 +13329,7 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev,
}
virPCIDeviceSetStubDriver(pci, VIR_PCI_STUB_DRIVER_VFIO);
} else if (STREQ(driverName, "kvm")) {
- if (!legacy) {
+ if (!kvm) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("KVM device assignment is currently not "
"supported on this system"));
diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c
index 4eb3f1d7f1..b6cb4d0980 100644
--- a/src/qemu/qemu_hostdev.c
+++ b/src/qemu/qemu_hostdev.c
@@ -132,44 +132,12 @@ qemuHostdevHostSupportsPassthroughVFIO(void)
}
-#if HAVE_LINUX_KVM_H
-# include <linux/kvm.h>
-bool
-qemuHostdevHostSupportsPassthroughLegacy(void)
-{
- int kvmfd = -1;
- bool ret = false;
-
- if ((kvmfd = open("/dev/kvm", O_RDONLY)) < 0)
- goto cleanup;
-
-# ifdef KVM_CAP_IOMMU
- if ((ioctl(kvmfd, KVM_CHECK_EXTENSION, KVM_CAP_IOMMU)) <= 0)
- goto cleanup;
-
- ret = true;
-# endif
-
- cleanup:
- VIR_FORCE_CLOSE(kvmfd);
-
- return ret;
-}
-#else
-bool
-qemuHostdevHostSupportsPassthroughLegacy(void)
-{
- return false;
-}
-#endif
-
-
static bool
qemuHostdevPreparePCIDevicesCheckSupport(virDomainHostdevDefPtr *hostdevs,
size_t nhostdevs,
virQEMUCapsPtr qemuCaps)
{
- bool supportsPassthroughKVM = qemuHostdevHostSupportsPassthroughLegacy();
+ bool supportsPassthroughKVM = virHostdevHostSupportsPassthroughKVM();
bool supportsPassthroughVFIO = qemuHostdevHostSupportsPassthroughVFIO();
size_t i;
diff --git a/src/qemu/qemu_hostdev.h b/src/qemu/qemu_hostdev.h
index 41f254ab81..be6faa2c35 100644
--- a/src/qemu/qemu_hostdev.h
+++ b/src/qemu/qemu_hostdev.h
@@ -25,7 +25,6 @@
# include "qemu_conf.h"
# include "domain_conf.h"
-bool qemuHostdevHostSupportsPassthroughLegacy(void);
bool qemuHostdevHostSupportsPassthroughVFIO(void);
int qemuHostdevUpdateActiveMediatedDevices(virQEMUDriverPtr driver,
diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
index 19ae001971..872528fdb2 100644
--- a/src/util/virhostdev.c
+++ b/src/util/virhostdev.c
@@ -2245,3 +2245,34 @@ virHostdevUpdateActiveDomainDevices(virHostdevManagerPtr mgr,
return 0;
}
+
+#if HAVE_LINUX_KVM_H
+# include <linux/kvm.h>
+bool
+virHostdevHostSupportsPassthroughKVM(void)
+{
+ int kvmfd = -1;
+ bool ret = false;
+
+ if ((kvmfd = open("/dev/kvm", O_RDONLY)) < 0)
+ goto cleanup;
+
+# ifdef KVM_CAP_IOMMU
+ if ((ioctl(kvmfd, KVM_CHECK_EXTENSION, KVM_CAP_IOMMU)) <= 0)
+ goto cleanup;
+
+ ret = true;
+# endif
+
+ cleanup:
+ VIR_FORCE_CLOSE(kvmfd);
+
+ return ret;
+}
+#else
+bool
+virHostdevHostSupportsPassthroughKVM(void)
+{
+ return false;
+}
+#endif
diff --git a/src/util/virhostdev.h b/src/util/virhostdev.h
index 7263f320a2..32fa36cdef 100644
--- a/src/util/virhostdev.h
+++ b/src/util/virhostdev.h
@@ -203,4 +203,5 @@ int virHostdevPCINodeDeviceReset(virHostdevManagerPtr mgr,
virPCIDevicePtr pci)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
+bool virHostdevHostSupportsPassthroughKVM(void);
#endif /* LIBVIRT_VIRHOSTDEV_H */
diff --git a/tests/virhostdevtest.c b/tests/virhostdevtest.c
index 4e067b10d1..1258338949 100644
--- a/tests/virhostdevtest.c
+++ b/tests/virhostdevtest.c
@@ -126,37 +126,6 @@ myInit(void)
return -1;
}
-# if HAVE_LINUX_KVM_H
-# include <linux/kvm.h>
-static bool
-virHostdevHostSupportsPassthroughKVM(void)
-{
- int kvmfd = -1;
- bool ret = false;
-
- if ((kvmfd = open("/dev/kvm", O_RDONLY)) < 0)
- goto cleanup;
-
-# ifdef KVM_CAP_IOMMU
- if ((ioctl(kvmfd, KVM_CHECK_EXTENSION, KVM_CAP_IOMMU)) <= 0)
- goto cleanup;
-
- ret = true;
-# endif
-
- cleanup:
- VIR_FORCE_CLOSE(kvmfd);
-
- return ret;
-}
-# else
-static bool
-virHostdevHostSupportsPassthroughKVM(void)
-{
- return false;
-}
-# endif
-
static int
testVirHostdevPreparePCIHostdevs_unmanaged(void)
{
--
2.20.1
5 years, 11 months
[libvirt] [PATCH] docs: Update drivers page to link to storage.html
by John Ferlan
Rather than duplicate a list of storage pool backends on the
drivers.html page, let's just link directly to the storage driver
page similar to how the node device driver is done.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
docs/drivers.html.in | 16 +---------------
1 file changed, 1 insertion(+), 15 deletions(-)
diff --git a/docs/drivers.html.in b/docs/drivers.html.in
index a66651df2f..4539eedbcd 100644
--- a/docs/drivers.html.in
+++ b/docs/drivers.html.in
@@ -6,7 +6,7 @@
<ul>
<li><a href="#hypervisor">Hypervisor drivers</a></li>
- <li><a href="#storage">Storage drivers</a></li>
+ <li><a href="storage.html">Storage drivers</a></li>
<li><a href="drvnodedev.html">Node device driver</a></li>
</ul>
@@ -39,19 +39,5 @@
<li><strong><a href="drvbhyve.html">Bhyve</a></strong> - The BSD Hypervisor</li>
</ul>
- <h2><a id="storage">Storage drivers</a></h2>
-
- <ul>
- <li><strong><a href="storage.html#StorageBackendDir">Directory backend</a></strong></li>
- <li><strong><a href="storage.html#StorageBackendFS">Local filesystem backend</a></strong></li>
- <li><strong><a href="storage.html#StorageBackendNetFS">Network filesystem backend</a></strong></li>
- <li><strong><a href="storage.html#StorageBackendLogical">Logical Volume Manager (LVM) backend</a></strong></li>
- <li><strong><a href="storage.html#StorageBackendDisk">Disk backend</a></strong></li>
- <li><strong><a href="storage.html#StorageBackendISCSI">iSCSI backend</a></strong></li>
- <li><strong><a href="storage.html#StorageBackendSCSI">SCSI backend</a></strong></li>
- <li><strong><a href="storage.html#StorageBackendMultipath">Multipath backend</a></strong></li>
- <li><strong><a href="storage.html#StorageBackendRBD">RBD (RADOS Block Device) backend</a></strong></li>
- <li><strong><a href="storage.html#StorageBackendSheepdog">Sheepdog backend</a></strong></li>
- </ul>
</body>
</html>
--
2.20.1
5 years, 11 months
[libvirt] [PATCH] qemu: Disable console device detach from live mode.
by Julio Faracco
Console Char devices cannot be attached as qemuDomainChrRemove()
function suggests. After moved to async mode,
qemuDomainRemoveChrDevice() is not part of the removal process. So, we
need to check if device is able to be detached before calling removal
procedures.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1447183
Signed-off-by: Julio Faracco <jcfaracco(a)gmail.com>
---
src/qemu/qemu_hotplug.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index f3c5f44a23..2c65df6d7b 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -5844,6 +5844,14 @@ qemuDomainDetachDeviceChr(virQEMUDriverPtr driver,
goto cleanup;
}
+ if (tmpChr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
+ tmpChr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL) {
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+ _("detaching serial console is not supported"));
+ goto cleanup;
+ }
+
+
/* guestfwd channels are not really -device rather than
* -netdev. We need to treat them slightly differently. */
guestfwd = tmpChr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL &&
--
2.20.1
5 years, 11 months