[PATCH 0/4] qemu: Move <hostdev> preparation into qemuDomainPrepareHostdev()

Now, technically 2/4 is a v3 of: https://listman.redhat.com/archives/libvir-list/2023-April/239368.html but when reviewing it, I realized that we can move more code around and this ended up bigger cleanup. Michal Prívozník (3): qemuDomainAttachHostDevice: Prepare device early and for all types qemu: Move <hostdev> SCSI path generation into qemuDomainPrepareHostdev() qemu: Remove empty functions Zhenzhong Duan (1): qemu: Move <hostdev/> PCI backend setting into qemuDomainPrepareHostdev() src/qemu/qemu_domain.c | 22 ++++++++++++++++ src/qemu/qemu_driver.c | 56 --------------------------------------- src/qemu/qemu_hostdev.c | 16 +++++------ src/qemu/qemu_hotplug.c | 11 +++----- src/qemu/qemu_process.c | 57 ---------------------------------------- src/qemu/qemu_process.h | 3 --- tests/qemuxml2argvmock.c | 17 ++++++++++++ tests/qemuxml2argvtest.c | 28 -------------------- 8 files changed, 50 insertions(+), 160 deletions(-) -- 2.39.2

When attaching a hostdev of a SCSI subsys, qemuDomainPrepareHostdev() is called. This makes sense because the function prepares just SCSI hostdevs ignoring others. But this will soon change. Thefore, move the function call out of qemuDomainAttachHostSCSIDevice() and into qemuDomainAttachHostDevice(). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/qemu/qemu_hotplug.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 3f45a48393..8902b40815 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2484,9 +2484,6 @@ qemuDomainAttachHostSCSIDevice(virQEMUDriver *driver, qemuAssignDeviceHostdevAlias(vm->def, &hostdev->info->alias, -1); - if (qemuDomainPrepareHostdev(hostdev, priv) < 0) - goto cleanup; - if (qemuProcessPrepareHostHostdev(hostdev) < 0) goto cleanup; @@ -2768,6 +2765,9 @@ qemuDomainAttachHostDevice(virQEMUDriver *driver, return -1; } + if (qemuDomainPrepareHostdev(hostdev, vm->privateData) < 0) + return -1; + switch (hostdev->source.subsys.type) { case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: if (qemuDomainAttachHostPCIDevice(driver, vm, -- 2.39.2

From: Zhenzhong Duan <zhenzhong.duan@intel.com> virsh command domxml-to-native failed with below error but start command succeed for same domain xml. "internal error: invalid PCI passthrough type 'default'" If a <hostdev> PCI backend is not set in the XML, the supported one is then chosen in qemuHostdevPreparePCIDevicesCheckSupport(). But this function is not called anywhere from qemuConnectDomainXMLToNative(). But qemuDomainPrepareHostdev() is. And it is also called from domain startup/hotplug code. Therefore, move the backend setting to the common path. And since qemuDomainPrepareHostdev() is called transitively from our qemuxml2argvtest, we can just drop the code in testCompareXMLToArgvCreateArgs() that preselects the backend (if a mock for qemuHostdevHostSupportsPassthroughVFIO() is provided. Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/qemu/qemu_domain.c | 12 ++++++++++++ src/qemu/qemu_hostdev.c | 16 +++++++--------- src/qemu/qemu_hotplug.c | 2 +- tests/qemuxml2argvmock.c | 7 +++++++ tests/qemuxml2argvtest.c | 6 ------ 5 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 63b13b6875..6de846f158 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -11275,6 +11275,18 @@ qemuDomainPrepareHostdev(virDomainHostdevDef *hostdev, } } + if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && + hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) { + bool supportsPassthroughVFIO = qemuHostdevHostSupportsPassthroughVFIO(); + virDomainHostdevSubsysPCIBackendType *backend = &hostdev->source.subsys.u.pci.backend; + + if (*backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT && + supportsPassthroughVFIO && + virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) { + *backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO; + } + } + return 0; } diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c index 45cd1066f0..8408928c00 100644 --- a/src/qemu/qemu_hostdev.c +++ b/src/qemu/qemu_hostdev.c @@ -156,7 +156,7 @@ qemuHostdevHostSupportsPassthroughVFIO(void) static bool qemuHostdevPreparePCIDevicesCheckSupport(virDomainHostdevDef **hostdevs, size_t nhostdevs, - virQEMUCaps *qemuCaps) + virQEMUCaps *qemuCaps G_GNUC_UNUSED) { bool supportsPassthroughVFIO = qemuHostdevHostSupportsPassthroughVFIO(); size_t i; @@ -173,17 +173,15 @@ qemuHostdevPreparePCIDevicesCheckSupport(virDomainHostdevDef **hostdevs, switch (*backend) { case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT: - if (supportsPassthroughVFIO && - virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) { - *backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO; + /* qemuDomainPrepareHostdev() should have set different value */ + if (supportsPassthroughVFIO) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("QEMU doesn't support VFIO PCI passthrough")); } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("host doesn't support passthrough of " - "host PCI devices")); - return false; + _("host doesn't support passthrough of host PCI devices")); } - - break; + return false; case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO: if (!supportsPassthroughVFIO) { diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 8902b40815..95ac0fd754 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1478,7 +1478,7 @@ qemuDomainAttachHostPCIDevice(virQEMUDriver *driver, &hostdev, 1, priv->qemuCaps, flags) < 0) return -1; - /* this could have been changed by qemuHostdevPreparePCIDevices */ + /* this could have been changed by qemuDomainPrepareHostdev */ backend = hostdev->source.subsys.u.pci.backend; switch (backend) { diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c index f566ec539a..863fdf0351 100644 --- a/tests/qemuxml2argvmock.c +++ b/tests/qemuxml2argvmock.c @@ -33,6 +33,7 @@ #include "virscsivhost.h" #include "virtpm.h" #include "virutil.h" +#include "qemu/qemu_hostdev.h" #include "qemu/qemu_interface.h" #include "qemu/qemu_command.h" #include <unistd.h> @@ -82,6 +83,12 @@ virSCSIVHostOpenVhostSCSI(int *vhostfd) return 0; } +bool +qemuHostdevHostSupportsPassthroughVFIO(void) +{ + return true; +} + int virNetDevTapCreate(char **ifname, const char *tunpath G_GNUC_UNUSED, diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 1808d9fc02..8333749eea 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -407,12 +407,6 @@ testCompareXMLToArgvCreateArgs(virQEMUDriver *drv, for (i = 0; i < vm->def->nhostdevs; i++) { virDomainHostdevDef *hostdev = vm->def->hostdevs[i]; - if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && - hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI && - hostdev->source.subsys.u.pci.backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT) { - hostdev->source.subsys.u.pci.backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO; - } - if (virHostdevIsSCSIDevice(hostdev)) { virDomainHostdevSubsysSCSI *scsisrc = &hostdev->source.subsys.u.scsi; -- 2.39.2

On Fri, Apr 14, 2023 at 03:44:16PM +0200, Michal Privoznik wrote:
From: Zhenzhong Duan <zhenzhong.duan@intel.com>
virsh command domxml-to-native failed with below error but start command succeed for same domain xml.
"internal error: invalid PCI passthrough type 'default'"
If a <hostdev> PCI backend is not set in the XML, the supported one is then chosen in qemuHostdevPreparePCIDevicesCheckSupport(). But this function is not called anywhere from qemuConnectDomainXMLToNative(). But qemuDomainPrepareHostdev() is. And it is also called from domain startup/hotplug code. Therefore, move the backend setting to the common path.
And since qemuDomainPrepareHostdev() is called transitively from our qemuxml2argvtest, we can just drop the code in testCompareXMLToArgvCreateArgs() that preselects the backend (if a mock for qemuHostdevHostSupportsPassthroughVFIO() is provided.
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/qemu/qemu_domain.c | 12 ++++++++++++ src/qemu/qemu_hostdev.c | 16 +++++++--------- src/qemu/qemu_hotplug.c | 2 +- tests/qemuxml2argvmock.c | 7 +++++++ tests/qemuxml2argvtest.c | 6 ------ 5 files changed, 27 insertions(+), 16 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 63b13b6875..6de846f158 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -11275,6 +11275,18 @@ qemuDomainPrepareHostdev(virDomainHostdevDef *hostdev, } }
+ if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && + hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) { + bool supportsPassthroughVFIO = qemuHostdevHostSupportsPassthroughVFIO(); + virDomainHostdevSubsysPCIBackendType *backend = &hostdev->source.subsys.u.pci.backend; + + if (*backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT && + supportsPassthroughVFIO && + virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) { + *backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO; + } + } + return 0; }
diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c index 45cd1066f0..8408928c00 100644 --- a/src/qemu/qemu_hostdev.c +++ b/src/qemu/qemu_hostdev.c @@ -156,7 +156,7 @@ qemuHostdevHostSupportsPassthroughVFIO(void) static bool qemuHostdevPreparePCIDevicesCheckSupport(virDomainHostdevDef **hostdevs,
I have a nagging feeling this terrible function needs its name changed, but that's mostly unrelated to this patch.
size_t nhostdevs, - virQEMUCaps *qemuCaps) + virQEMUCaps *qemuCaps G_GNUC_UNUSED)
This is no unused in couple of callers above and could be removed.
{ bool supportsPassthroughVFIO = qemuHostdevHostSupportsPassthroughVFIO(); size_t i; @@ -173,17 +173,15 @@ qemuHostdevPreparePCIDevicesCheckSupport(virDomainHostdevDef **hostdevs,
switch (*backend) { case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT: - if (supportsPassthroughVFIO && - virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) { - *backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO;
Since this is now not setting any defaults the comment above (not in context here, but it says "assign defaults ...") should be removed as well.
+ /* qemuDomainPrepareHostdev() should have set different value */ + if (supportsPassthroughVFIO) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("QEMU doesn't support VFIO PCI passthrough"));
This error is also thrown in three more places (which itself is mind-blowing), but with a different wording. For the sake of translations they could be unified so that there are not two different strings for the same error. If we want this function to be the know-it-all of all related checks then it should maybe replace the other places that check (almost) the same things. Look for "VFIO PCI device assignment" in the codebase to find the other error messages I'm mentioning here.
} else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("host doesn't support passthrough of " - "host PCI devices")); - return false; + _("host doesn't support passthrough of host PCI devices"));
What's really weird here is that the function just uses a host capability to decide which error message to use. But the logic is not visible from here because it depends on another function's behaviour, qemuDomainPrepareHostdev in this case. The comment kind of papers over it. Bear with me for a bit of analysis. qemuHostdevPreparePCIDevicesCheckSupport is only called from qemuHostdevPreparePCIDevices which is called from: - qemuDomainAttachHostPCIDevice (during hotplug) - qemuHostdevPrepareDomainDevices (during startup) Well, during hotplug there is a call to qemuDomainPrepareHostdev just before going down the rabbit hole into ...CheckSupport. And during startup/migration the other function is called from qemuProcessPrepareHost which is (and must) be always called before qemuProcessPrepareDomain which calls qemuDomainPrepareHostdev as well. My question is why we then do not error out right in qemuDomainPrepareHostdev which has basically the same condition and it is easier to see the logic behind the error message?
} - - break; + return false;
case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO: if (!supportsPassthroughVFIO) { diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 8902b40815..95ac0fd754 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1478,7 +1478,7 @@ qemuDomainAttachHostPCIDevice(virQEMUDriver *driver, &hostdev, 1, priv->qemuCaps, flags) < 0) return -1;
- /* this could have been changed by qemuHostdevPreparePCIDevices */ + /* this could have been changed by qemuDomainPrepareHostdev */ backend = hostdev->source.subsys.u.pci.backend;
I think this comment was here just to explain why is this variable not initialized in its declaration. With the above change it can be set there and these two lines removed instead.

When preparing a SCSI <hostdev/> with passthrough of a host SCSI adapter (i.e. no protocol), a virStorageSource structure is initialized and stored inside virDomainHostdevDef. But the source structure is filled in many places, with almost the same code. Firstly, qemuProcessPrepareHostHostdev() and qemuConnectDomainXMLToNativePrepareHostHostdev() are the same. Secondly, qemuDomainPrepareHostdev() allocates the src structure, only to let qemuProcessPrepareHostHostdev() fill src->path later. Well, src->path can be filled at the same place where the src structure is allocated (qemuDomainPrepareHostdev()) which renders the other two functions needless. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/qemu/qemu_domain.c | 10 ++++++++++ src/qemu/qemu_driver.c | 32 +------------------------------- src/qemu/qemu_process.c | 32 +------------------------------- tests/qemuxml2argvmock.c | 10 ++++++++++ tests/qemuxml2argvtest.c | 22 ---------------------- 5 files changed, 22 insertions(+), 84 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6de846f158..3925de4d49 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -11230,7 +11230,9 @@ qemuDomainPrepareHostdev(virDomainHostdevDef *hostdev, { if (virHostdevIsSCSIDevice(hostdev)) { virDomainHostdevSubsysSCSI *scsisrc = &hostdev->source.subsys.u.scsi; + virDomainHostdevSubsysSCSIHost *scsihostsrc = &scsisrc->u.host; virStorageSource *src = NULL; + g_autofree char *devstr = NULL; switch ((virDomainHostdevSCSIProtocolType) scsisrc->protocol) { case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_NONE: @@ -11238,7 +11240,15 @@ qemuDomainPrepareHostdev(virDomainHostdevDef *hostdev, scsisrc->u.host.src = virStorageSourceNew(); src = scsisrc->u.host.src; + if (!(devstr = virSCSIDeviceGetSgName(NULL, + scsihostsrc->adapter, + scsihostsrc->bus, + scsihostsrc->target, + scsihostsrc->unit))) + return -1; + src->type = VIR_STORAGE_TYPE_BLOCK; + src->path = g_strdup_printf("/dev/%s", devstr); break; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 28e470e4a2..701656696b 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6166,38 +6166,8 @@ static char static int -qemuConnectDomainXMLToNativePrepareHostHostdev(virDomainHostdevDef *hostdev) +qemuConnectDomainXMLToNativePrepareHostHostdev(virDomainHostdevDef *hostdev G_GNUC_UNUSED) { - if (virHostdevIsSCSIDevice(hostdev)) { - virDomainHostdevSubsysSCSI *scsisrc = &hostdev->source.subsys.u.scsi; - - switch ((virDomainHostdevSCSIProtocolType) scsisrc->protocol) { - case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_NONE: { - virDomainHostdevSubsysSCSIHost *scsihostsrc = &scsisrc->u.host; - virStorageSource *src = scsisrc->u.host.src; - g_autofree char *devstr = NULL; - - if (!(devstr = virSCSIDeviceGetSgName(NULL, - scsihostsrc->adapter, - scsihostsrc->bus, - scsihostsrc->target, - scsihostsrc->unit))) - return -1; - - src->path = g_strdup_printf("/dev/%s", devstr); - break; - } - - case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI: - break; - - case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_LAST: - default: - virReportEnumRangeError(virDomainHostdevSCSIProtocolType, scsisrc->protocol); - return -1; - } - } - return 0; } diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index b9e9a7d320..ec07f86d35 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6510,38 +6510,8 @@ qemuProcessPrepareDomainHostdevs(virDomainObj *vm, int -qemuProcessPrepareHostHostdev(virDomainHostdevDef *hostdev) +qemuProcessPrepareHostHostdev(virDomainHostdevDef *hostdev G_GNUC_UNUSED) { - if (virHostdevIsSCSIDevice(hostdev)) { - virDomainHostdevSubsysSCSI *scsisrc = &hostdev->source.subsys.u.scsi; - - switch ((virDomainHostdevSCSIProtocolType) scsisrc->protocol) { - case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_NONE: { - virDomainHostdevSubsysSCSIHost *scsihostsrc = &scsisrc->u.host; - virStorageSource *src = scsisrc->u.host.src; - g_autofree char *devstr = NULL; - - if (!(devstr = virSCSIDeviceGetSgName(NULL, - scsihostsrc->adapter, - scsihostsrc->bus, - scsihostsrc->target, - scsihostsrc->unit))) - return -1; - - src->path = g_strdup_printf("/dev/%s", devstr); - break; - } - - case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI: - break; - - case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_LAST: - default: - virReportEnumRangeError(virDomainHostdevSCSIProtocolType, scsisrc->protocol); - return -1; - } - } - return 0; } diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c index 863fdf0351..2b37b6c258 100644 --- a/tests/qemuxml2argvmock.c +++ b/tests/qemuxml2argvmock.c @@ -89,6 +89,16 @@ qemuHostdevHostSupportsPassthroughVFIO(void) return true; } +char * +virSCSIDeviceGetSgName(const char *sysfs_prefix G_GNUC_UNUSED, + const char *adapter G_GNUC_UNUSED, + unsigned int bus G_GNUC_UNUSED, + unsigned int target G_GNUC_UNUSED, + unsigned long long unit G_GNUC_UNUSED) +{ + return g_strdup_printf("sg0"); +} + int virNetDevTapCreate(char **ifname, const char *tunpath G_GNUC_UNUSED, diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 8333749eea..919e69e306 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -404,28 +404,6 @@ testCompareXMLToArgvCreateArgs(virQEMUDriver *drv, disk->src->hostcdrom = true; } - for (i = 0; i < vm->def->nhostdevs; i++) { - virDomainHostdevDef *hostdev = vm->def->hostdevs[i]; - - if (virHostdevIsSCSIDevice(hostdev)) { - virDomainHostdevSubsysSCSI *scsisrc = &hostdev->source.subsys.u.scsi; - - switch ((virDomainHostdevSCSIProtocolType) scsisrc->protocol) { - case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_NONE: - scsisrc->u.host.src->path = g_strdup("/dev/sg0"); - break; - - case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI: - break; - - case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_LAST: - default: - virReportEnumRangeError(virDomainHostdevSCSIProtocolType, scsisrc->protocol); - return NULL; - } - } - } - if (vm->def->vsock) { virDomainVsockDef *vsock = vm->def->vsock; qemuDomainVsockPrivate *vsockPriv = -- 2.39.2

After previous cleanup, there are some functions that do nothing: qemuConnectDomainXMLToNativePrepareHostHostdev() qemuConnectDomainXMLToNativePrepareHost() qemuProcessPrepareHostHostdev() qemuProcessPrepareHostHostdevs() Remove them. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/qemu/qemu_driver.c | 26 -------------------------- src/qemu/qemu_hotplug.c | 3 --- src/qemu/qemu_process.c | 27 --------------------------- src/qemu/qemu_process.h | 3 --- 4 files changed, 59 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 701656696b..f38847cf02 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6165,29 +6165,6 @@ static char } -static int -qemuConnectDomainXMLToNativePrepareHostHostdev(virDomainHostdevDef *hostdev G_GNUC_UNUSED) -{ - return 0; -} - - -static int -qemuConnectDomainXMLToNativePrepareHost(virDomainObj *vm) -{ - size_t i; - - for (i = 0; i < vm->def->nhostdevs; i++) { - virDomainHostdevDef *hostdev = vm->def->hostdevs[i]; - - if (qemuConnectDomainXMLToNativePrepareHostHostdev(hostdev) < 0) - return -1; - } - - return 0; -} - - static char *qemuConnectDomainXMLToNative(virConnectPtr conn, const char *format, const char *xmlData, @@ -6244,9 +6221,6 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn, VIR_QEMU_PROCESS_START_COLD) < 0) return NULL; - if (qemuConnectDomainXMLToNativePrepareHost(vm) < 0) - return NULL; - if (!(cmd = qemuProcessCreatePretendCmdBuild(vm, NULL))) return NULL; diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 95ac0fd754..fc4406c1b5 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2484,9 +2484,6 @@ qemuDomainAttachHostSCSIDevice(virQEMUDriver *driver, qemuAssignDeviceHostdevAlias(vm->def, &hostdev->info->alias, -1); - if (qemuProcessPrepareHostHostdev(hostdev) < 0) - goto cleanup; - if (!(data = qemuBuildHostdevSCSIAttachPrepare(hostdev, &backendalias, priv->qemuCaps))) goto cleanup; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index ec07f86d35..8414302f7c 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6509,29 +6509,6 @@ qemuProcessPrepareDomainHostdevs(virDomainObj *vm, } -int -qemuProcessPrepareHostHostdev(virDomainHostdevDef *hostdev G_GNUC_UNUSED) -{ - return 0; -} - - -static int -qemuProcessPrepareHostHostdevs(virDomainObj *vm) -{ - size_t i; - - for (i = 0; i < vm->def->nhostdevs; i++) { - virDomainHostdevDef *hostdev = vm->def->hostdevs[i]; - - if (qemuProcessPrepareHostHostdev(hostdev) < 0) - return -1; - } - - return 0; -} - - /** * qemuProcessRebootAllowed: * @def: domain definition @@ -7233,10 +7210,6 @@ qemuProcessPrepareHost(virQEMUDriver *driver, if (qemuProcessPrepareHostStorage(driver, vm, flags) < 0) return -1; - VIR_DEBUG("Preparing hostdevs (host-side)"); - if (qemuProcessPrepareHostHostdevs(vm) < 0) - return -1; - VIR_DEBUG("Preparing external devices"); if (qemuExtDevicesPrepareHost(driver, vm) < 0) return -1; diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index b171f0464c..5d1b24a038 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -111,9 +111,6 @@ int qemuProcessPrepareDomain(virQEMUDriver *driver, int qemuProcessOpenVhostVsock(virDomainVsockDef *vsock); -int qemuProcessPrepareHostHostdev(virDomainHostdevDef *hostdev); - - int qemuProcessPrepareHostBackendChardevHotplug(virDomainObj *vm, virDomainDeviceDef *dev) G_NO_INLINE; -- 2.39.2
participants (2)
-
Martin Kletzander
-
Michal Privoznik