mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 07:17:44 +00:00
qemu: Format mdevs on qemu command line
Format the mediated devices on the qemu command line as -device vfio-pci,sysfsdev='/path/to/device/in/syfs'. Signed-off-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
c8e6775f30
commit
ef18a50bfb
@ -58,6 +58,7 @@
|
|||||||
#include "virscsi.h"
|
#include "virscsi.h"
|
||||||
#include "virnuma.h"
|
#include "virnuma.h"
|
||||||
#include "virgic.h"
|
#include "virgic.h"
|
||||||
|
#include "virmdev.h"
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
# include <linux/capability.h>
|
# include <linux/capability.h>
|
||||||
#endif
|
#endif
|
||||||
@ -5220,6 +5221,31 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
qemuBuildHostdevMediatedDevStr(const virDomainDef *def,
|
||||||
|
virDomainHostdevDefPtr dev,
|
||||||
|
virQEMUCapsPtr qemuCaps)
|
||||||
|
{
|
||||||
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||||
|
virDomainHostdevSubsysMediatedDevPtr mdevsrc = &dev->source.subsys.u.mdev;
|
||||||
|
char *ret = NULL;
|
||||||
|
|
||||||
|
virBufferAddLit(&buf, "vfio-pci");
|
||||||
|
virBufferAsprintf(&buf, ",sysfsdev=%s",
|
||||||
|
virMediatedDeviceGetSysfsPath(mdevsrc->uuidstr));
|
||||||
|
|
||||||
|
if (qemuBuildDeviceAddressStr(&buf, def, dev->info, qemuCaps) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (virBufferCheckError(&buf) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
ret = virBufferContentAndReset(&buf);
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
virBufferFreeAndReset(&buf);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuBuildHostdevCommandLine(virCommandPtr cmd,
|
qemuBuildHostdevCommandLine(virCommandPtr cmd,
|
||||||
@ -5408,6 +5434,25 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd,
|
|||||||
VIR_FREE(devstr);
|
VIR_FREE(devstr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* MDEV */
|
||||||
|
if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
|
||||||
|
subsys->type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV) {
|
||||||
|
|
||||||
|
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("VFIO PCI device assignment is not "
|
||||||
|
"supported by this version of qemu"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
virCommandAddArg(cmd, "-device");
|
||||||
|
if (!(devstr =
|
||||||
|
qemuBuildHostdevMediatedDevStr(def, hostdev, qemuCaps)))
|
||||||
|
return -1;
|
||||||
|
virCommandAddArg(cmd, devstr);
|
||||||
|
VIR_FREE(devstr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -168,6 +168,11 @@ qemuBuildSCSIVHostHostdevDevStr(const virDomainDef *def,
|
|||||||
virQEMUCapsPtr qemuCaps,
|
virQEMUCapsPtr qemuCaps,
|
||||||
char *vhostfdName);
|
char *vhostfdName);
|
||||||
|
|
||||||
|
char *
|
||||||
|
qemuBuildHostdevMediatedDevStr(const virDomainDef *def,
|
||||||
|
virDomainHostdevDefPtr dev,
|
||||||
|
virQEMUCapsPtr qemuCaps);
|
||||||
|
|
||||||
char *qemuBuildRedirdevDevStr(const virDomainDef *def,
|
char *qemuBuildRedirdevDevStr(const virDomainDef *def,
|
||||||
virDomainRedirdevDefPtr dev,
|
virDomainRedirdevDefPtr dev,
|
||||||
virQEMUCapsPtr qemuCaps);
|
virQEMUCapsPtr qemuCaps);
|
||||||
|
Loading…
Reference in New Issue
Block a user